Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Getting the full program name in managed C++ (http://www.go4expert.com/forums/getting-program-managed-cpp-t28797/)

robena 27Jul2012 21:48

Getting the full program name in managed C++
 
Hi,

I have a managed C++ project starting with:


Code: C++

[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?

robena 27Jul2012 23:04

Re: Getting the full program name in managed C++
 
Well, found it finally:

Code:

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



All times are GMT +5.5. The time now is 18:35.