[php]
char* GetExecutablePath(char* ExecutableName)
{
//Find process
PROCESSENTRY32 Pe;
Pe.dwSize = sizeof( PROCESSENTRY32 );
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL,NULL);
Process32First(snapshot,&Pe);
do {
if( !strcmp(Pe.szExeFile,ExecutableName) )
break;
} while(Process32Next(snapshot,&Pe));
//Find executable module and return path
MODULEENTRY32 Me;
Me.dwSize = sizeof( MODULEENTRY32 );
HANDLEh snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,Pe.dw32 thProcessID);
Module32First(hsnapshot,&Me);
do {
if( !strcmp(Me.szModule,Executable) )
return Me.szExePath;
} while(Module32Next(hsnapshot,&Me);
return NULL;
}
int main()
{
char* path = GetExecutablePath("winmine.exe");
char* Filename = "\\Untitled.txt";
path += Filename;
ofstream File(path); //creates if doesn't exist
}
[/php]
Idk if that's going to work, I'm not on Windows, can't test anything..