Sign in to follow this  

[.net] getting full path of my .exe

Recommended Posts

This is very OS Specific...

For windows 32:As SiCrane mentioned, you want to use GetModuleFilename to do this. This will give you the desired behavior you are looking for. The syntax for that is:

DWORD GetModuleFileName(
HMODULE hModule,
LPTSTR lpFilename,

You will want to pass NULL as hModule, that represents the currently running process. make sure lpFilename points to an already created buffer zone. That means if you are creating your data on the heap, be sure to new it beforehand, and delete it afterward. nSize should be the number of bytes that your buffer can hold, it is important that this is set to the size of the buffer (or smaller) or you could easily have yourself a buffer overrun.

Also, for some reason i think there may be an undesired differing behaviour on Win95, though i may be thinking of the TOOLHELP and PSAPI functionality which i find i use quite often (remote process enumeration and such).

Anyways, good luck!

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this