Is there a way to access the equivilent of argv[0] when you have WinMain()?
In other words, is there a Windows function to return the name of the executable?
Is there a way to access the equivilent of argv[0] when you have WinMain()?
In other words, is there a Windows function to return the name of the executable?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Please someone correct me if I'm wrong =P but I think the equivalent is LPSTR
You could always use the function GetModuleFileNameCode:int WINAPI WinMain(HINSTANCE,HISTANCE,LPSTR,int);
example from winprog.org's site:
Code:case WM_LBUTTONDOWN: { char szFileName[MAX_PATH]; HINSTANCE hInstance = GetModuleHandle(NULL); GetModuleFileName(hInstance, szFileName, MAX_PATH); MessageBox(hwnd, szFileName, "This program is:", MB_OK | MB_ICONINFORMATION); } break;
Last edited by Homunculus; 03-05-2006 at 11:15 AM.
no..
LPSTR lpCmdLine is used for any parameters passed to the program, or if you drag and drop a file on the program it will have the path of the file.
Just use GetModuleFileName, and pass NULL as the first parameter. If you need the rest of the arguments, use GetCommandLine or the lpCmdLine variable passed to WinMain().
Thanks.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.