Tân Dương Đình Tân Dương Đình - 1 year ago 128
C++ Question

GetModuleFileName dose not return really the path of Executable file

I am coding a program as service using c++, when I test it as a normal program, function

return really path. But when I try to install my program as service,
instead return real path, it return C:\Windows\System32\

How can I fix it, Thank you
(I hope you understand me)

Answer Source

Working directory for Windows services is always %WINDIR%\System32.

To get directory, where your executable resides, simply call GetModuleFileName with NULL for hModule argument, and manually strip executable name.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download