Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: GetModuleName returns extra characters


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Apr 23, 2018 2:20 PM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Greg Reese

Posts: 100
Registered: 7/15/05
GetModuleName returns extra characters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 1:44 PM
I have a FireMonkey program in Builder 10.2.3. If my executable is c:\blahblah\myproject\win32\debug\myprogram.exe
the three lines below all return c:\blahblah\myproject\.\win32\debug\myprogram.exe (an extra \. between myproject and win32).

String file1 = GetModuleName( (unsigned int)HInstance );
String file2 = GetModuleName( (unsigned int)MainInstance );
String file3 = GetModuleName( 0 );


Any suggestions?

Thanks.
Greg Reese
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: GetModuleName returns extra characters  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 23, 2018 2:20 PM   in response to: Greg Reese in response to: Greg Reese
Greg Reese wrote:

I have a FireMonkey program in Builder 10.2.3. If my executable is
c:\blahblah\myproject\win32\debug\myprogram.exe the three lines below
all return c:\blahblah\myproject\.\win32\debug\myprogram.exe (an
extra \. between myproject and win32).

String file1 = GetModuleName( (unsigned int)HInstance );
String file2 = GetModuleName( (unsigned int)MainInstance );
String file3 = GetModuleName( 0 );


Any suggestions?

That is normal and expected behavior. That is the actual path that was
used to start your process. It is not the path to the EXE file that
the process was created from. If you don't like the extra characters
(which are perfectly valid), you can pass the path string to the Win32
API GetFullPathName() function:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa364963.aspx

Do you have the same output if you use ParamStr(0) instead?

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02