PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Saving state in same directory as .EXE

I'd like to save the game in the same directory as the exe. I think this is probably a good idea in case the state gets quite large, so if they installed to Compact Flash it doesn't eat up RAM.

What do you think?

I'm also looking for ways to do this, because obviously there is not current directory. Is it possible to get the filename of the current process, perhaps with GetCurrentProcessID or something, or with GetCommandLine()? And then get the directory.

Anyone done this before and can advise The Right Way (tm)?
Conan · 15 Jul 2002, 21:42 UTC — Finding the .exe's location
Taken from eVC help
The PocketPC function you need is:-

GetModuleFileName

This function gets a module file name.

WINAPI DWORD GetModuleFileName(
HMODULE hModule,
LPWSTR lpFilename,
DWORD nSize );
Parameters
hModule
[in] Handle to the module whose executable filename is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file used to create the calling process.
[/code]
Thanks Conan, that was just what I was after!