I got a small problem.
I use GetModuleFileName to obtain the file name of my program's exe. But this file name is upper case letters only. How can i convert this upper case file name and it's entire path to it's "real" case? For example:
My Program's exe: C:\Program Files\Program\program.exe
FileName returned by GetModuleFileName: C:\PROGRAM FILES\PROGRAM\PROGRAM.EXE
Now i need to convert
C:\Program Files\Program\program.exe
Of course i know how to convert upper case letters to lower case letters, but that's not the problem. The problem is i don't know which letters of the file name are upper/lower case in their "real case" (the case that is used by the file system).
It could be
C:\program files\Program\program.exe
C.\Program files\program\Program.exe
C.\program Files\program\program.exe
or whatever.
I hope you know what i mean...
Posted on 2002-01-13 07:25:38 by darester
could you please post you source? My code returns the path in 'real' case (not uppercase, as you describe):

.model flat, stdcall
option casemap :none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

szFileNameBuffer db 512 dup (?)


invoke GetModuleFileName, 0, addr szFileNameBuffer, 512

invoke MessageBox, 0, addr szFileNameBuffer, 0, 0

invoke ExitProcess, 0

end start

Posted on 2002-01-13 07:35:03 by bazik
well, my code is written in c, but i think that doesn't matter:

char szFile[_MAX_PATH];
GetModuleFileName(NULL, szFile, _MAX_PATH);
MessageBox(NULL, szFile, "Info", MB_OK);
Posted on 2002-01-13 07:56:51 by darester
Hmm.... this C code (compiled with VC++ 6) also shows me the path in the correct case:

#include <windows.h>

#pragma comment(linker,"/ENTRY:main /FILEALIGN:0x200 /MERGE:.data=.text /MERGE:.rdata=.text /SECTION:.text,EWR /IGNORE:4078")

void main()
char szFile[_MAX_PATH];
GetModuleFileName(NULL, szFile, _MAX_PATH);
MessageBox(NULL, szFile, "Info", MB_OK);

Wich OS do you have? I'm running WinXP Pro. Perhaps this is a Win9x problem :confused:
Posted on 2002-01-13 08:12:26 by bazik
yeah i use win9x. maybe that's the problem :)
but i'm not sure...
Posted on 2002-01-13 08:25:16 by darester