• ### Popular Now

• 13
• 18
• 19
• 27
• 10

#### Archived

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

# Where is the EXE - VB6

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

## Recommended Posts

I am a begginer programmer so I never yet had to consider what happens to my program when it is not on my computer. My main problem is - How do I know where the exe, and the files, that are needed for it, located? if I have a ini file, the win api function excpects a full address(c:\bla\blabla\...\info.ini) not just "info.ini" to read or write to the file but I do not know the full address since it is located in the same folder as the exe. Also I know that Vb has a setup wizard that lets you make your own setup program - but is there anything newer/better than that because it does not look good. THANKS

##### Share on other sites
Use GetModuleFileName to get the current EXE''s filename:
char sExeFilename[MAX_PATH];GetModuleFileName(0, // get current module''s path  sExeFilename, MAX_PATH);

Further Explanation
Normally when you run a program, the current directory is set to the directory the EXE is in, so when you try to open a file, such as "info.ini", it looks in the current directory (the EXE''s directory) for info.ini.

Windows'' INI functions, as you have stated, do not look in the EXE''s directory, however. You have to specify the entire path to modify INI files, hence the need for GetModuleFileName to determine the EXE''s directory.

Installation Programs
I use Inno Setup. It''s simple and free! Be sure to download ISTool so that you can create installation scripts graphically.

##### Share on other sites
You could also use App.Path. This returns the full path to the current directory that the app is running in as a string.

------------------------------------------------------------
Open your eyes and free your mind
That you may see the subtle wonder
Of the worlds we live in...