Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Prozak

How to get name of exe?

This topic is 5326 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Console app: should be argv[0].

Windows app: GetModuleFileName() with the argument as the handle received from GetModuleHandle() with a null argument.

Share this post


Link to post
Share on other sites
quote:
Original post by msn12b
Or GetModuleNameFile(NULL, ...).

...

edit: fixed function call after looking it up.



Fix it again. You got the Name and File part of the function call switched. (Besides which, using NULL as the argument to GetModuleFileName() may not return the exe''s name.)

Share this post


Link to post
Share on other sites
Even in a Windows application, you''ll still have access to argc & argv.

I don''t have MSDN with me right now, so not sure if they''re documented well, but lookup:

__argc
__argv

Supposidly I hear these don''t work with MFC, but I wouldn''t be sure as to why not.

Share this post


Link to post
Share on other sites
quote:
Original post by SiCrane
using NULL as the argument to GetModuleFileName() may not return the exe's name.

According to MSDN,

GetModuleFileName(NULL, ...)

and

GetModuleFileName(GetModuleHandle(NULL), ...)

sound quite identical:

Under GetModuleHandle:
lpModuleName
If this parameter is NULL, GetModuleHandle
returns a handle to the file used to create
the calling process (.exe file).

Under GetModuleFileName:
hModule
Handle to the module whose path is being
requested. If this parameter is NULL,
GetModuleFileName retrieves the path of
the executable file of the current process.

So GetModuleFileName(NULL) sounds like it should work just fine.

[edited by - Agony on January 14, 2004 3:15:54 PM]

Share this post


Link to post
Share on other sites
That''s interesting. The text in the copy of MSDN on my computer is subtly different:
quote:

hModule
[in] Handle to the module whose path is being requested. If this parameter is NULL, GetModuleFileName retrieves the path for the current module.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!