1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Getting the full program name in managed C++

Discussion in 'C++' started by robena, Jul 27, 2012.

  1. robena

    robena New Member

    Joined:
    Jan 28, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I have a managed C++ project starting with:


    Code:
    [STAThreadAttribute]
    int main(array<System::String ^> ^args)

    args[0] is not the program name, but the first argument.

    How do I get the program name, with its full path, i.e. something like "c:\App\foo.exe"?

    GetCommandLine() and GetModuleFileName() don't seem to work with managed code, what can I use?
     
  2. robena

    robena New Member

    Joined:
    Jan 28, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Well, found it finally:

    Code:
    Process^ currentProcess = Process::GetCurrentProcess();
    String ^Sbin = currentProcess->MainModule->FileName;
     

Share This Page