开发者

Executable path

开发者 https://www.devze.com 2023-01-31 16:45 出处:网络
I need to find the path of where my program is running. Using argv[0] doesn\'t seem to work bec开发者_如何学Goause the program has to be run on the windows console, for example, C:\\ >player parameter

I need to find the path of where my program is running. Using argv[0] doesn't seem to work bec开发者_如何学Goause the program has to be run on the windows console, for example, C:\ >player parameter1 parameter2 and I only get player on argv[0].

How can I accomplish this?


You can use Windows' GetModuleFileName function to obtain the path of the executable by setting the hModule parameter to NULL.


Not sure exactly what you mean by "path of where my program is running" ... if you mean the current working directory, getcwd in c/c++ would get you what you want.

EDIT: As was also mentioned, GetModuleFileName will retrieve the actual EXE name ... see here for similar question posted on another Q&A site.

0

精彩评论

暂无评论...
验证码 换一张
取 消