Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

12
  • 3
    I think this is the only answer here that answers the question, and does so for both Windows and Linux. Nice job. Commented Oct 14, 2008 at 19:31
  • 7
    Boo for /proc/pid/exe - Not supported on OS X for some reason. Commented Jul 4, 2009 at 7:53
  • 31
    When I see code that looks at /proc part of me dies a little. All the world is not Linux, and even on that one platform /proc should be considered subject to change from version to version, arch to arch, etc. Commented Jan 28, 2010 at 0:29
  • 4
    if they launch using an aliased command on Linux is the argv[0] the "name of the command" or expanded? Commented Aug 4, 2010 at 8:16
  • 21
    How about add char pBuf[256]; size_t len = sizeof(pBuf); to let the solution more clearly. Commented Oct 5, 2016 at 13:22