2

i need to get path to current executable in service, but when using GetModuleFileNameW or global variable _pgmptr i always get lowercase path, which is incorrect for me.

example: original path is C:/MyApp/app.exe and GetModuleFileNameW always returns c:/myapp/app.exe

problem doesnt occur in desktop applications, only services. how can i get the correct case path?

  • Why is it "incorrect" for you? Filenames and paths are seldom case sensitive in Windows. – Some programmer dude Jul 06 '15 at 07:17
  • 1
    That probably has something to do with the way you registered the service. Try QueryFullProcessImageName() instead. – Hans Passant Jul 06 '15 at 07:19
  • QueryFullProcessImageName is not working, i forgot to say i use windows XP. my program is mostly a linux port, so these two paths are different for me –  Jul 06 '15 at 07:31
  • Are you comparing the string you get from `GetModuleFileNameW` with some other string? Where do you get the other string from? Maybe you should conform to the platform you're running on and use case-insensitive compare? And what is the *actual* problem you're trying to solve? (Related reading: [What is the XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)) – Some programmer dude Jul 06 '15 at 14:54
  • ive already solved it, i split path into separate folders and add them to list then iterate over parent directory of each folder in list to get correct values. i think thats the only solution, its working so ill leave it like that –  Jul 06 '15 at 15:00

0 Answers0