For Programmers: Free Programming Magazines  


Home > Archive > VC Language > January 2006 > Stange GetModuleFilename() behaviour









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Stange GetModuleFilename() behaviour
Murrgon

2006-01-27, 7:05 pm

Okay, a collegue of mine just did a full reinstall of WinXP
and VC7.1. After getting the latest version of our source
code from source control and building it all, the results
returned from GetModuleFilename() seem to have changed.

Instead of giving the module name as stored on disk, with
mixed case intact, it converts the whole path to lower case.
This is the first time I have seen this function modify
the case of the path it returns.

Can anyone tell me why it is doing this?
Thanks
Doug Harrison [MVP]

2006-01-27, 7:05 pm

On Fri, 27 Jan 2006 13:25:51 -0500, Murrgon <murrgon@hotmail.com> wrote:

>Okay, a collegue of mine just did a full reinstall of WinXP
>and VC7.1. After getting the latest version of our source
>code from source control and building it all, the results
>returned from GetModuleFilename() seem to have changed.
>
>Instead of giving the module name as stored on disk, with
>mixed case intact, it converts the whole path to lower case.
>This is the first time I have seen this function modify
>the case of the path it returns.
>
>Can anyone tell me why it is doing this?


http://msdn.microsoft.com/library/d...ulefilename.asp
<q>
The string returned will use the same format that was specified when the
module was loaded. Therefore, the path can be a long or short file name,
and can use the prefix "\\?\".
....
If a DLL is loaded in two processes, its file name in one process may
differ in case from its file name in the other process.
</q>

--
Doug Harrison
Visual C++ MVP
Murrgon

2006-01-27, 7:05 pm

Doug Harrison [MVP] wrote:
> <q>
> The string returned will use the same format that was specified when the
> module was loaded. Therefore, the path can be a long or short file name,
> and can use the prefix "\\?\".
> ...
> If a DLL is loaded in two processes, its file name in one process may
> differ in case from its file name in the other process.
> </q>


The docs say "DLL", but in our case, we're asking for the name of the
executable, which is not being loaded by two different processes. It
seems rather odd that the OS cannot provide consistently formatted names.
It is, after all, getting the name from the file system, I would presume.
Victor Bazarov

2006-01-27, 7:05 pm

Murrgon wrote:
> Doug Harrison [MVP] wrote:
>
>
>
> The docs say "DLL", but in our case, we're asking for the name of the
> executable, which is not being loaded by two different processes. It
> seems rather odd that the OS cannot provide consistently formatted names.
> It is, after all, getting the name from the file system, I would presume.


But with drive mappings and other things, wouldn't the same file be
accessible through more than one "route", as it were? How should the
system pick one for you? And see the note, it will use "the same format
that was specified when module was loaded". That means if you call your
EXE with a short filename, you get the short version, and so on, the case
probably included into consideration. If you specify the right case for
all characters in the name, you get the right one (with case preserved),
and if you run the EXE by giving all-lowercase letters, it might be too
smart for its own good and convert everything to lower case...

V
--
Please remove capital As from my address when replying by mail
Sorry, I do not respond to top-posted replies, please don't ask
Murrgon

2006-01-27, 7:05 pm

Victor Bazarov wrote:
> But with drive mappings and other things, wouldn't the same file be
> accessible through more than one "route", as it were? How should the
> system pick one for you? And see the note, it will use "the same format
> that was specified when module was loaded". That means if you call your
> EXE with a short filename, you get the short version, and so on, the case
> probably included into consideration. If you specify the right case for
> all characters in the name, you get the right one (with case preserved),
> and if you run the EXE by giving all-lowercase letters, it might be too
> smart for its own good and convert everything to lower case...


Interesting how this triggered the thought processes. On the machine
in question, when attempting to debug the application, the user had
*typed* in the path to the executable, all in lower case. Interesting
discovery.

Thank you all for your help.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com