Pfad herausfinden
-
Hi,
wie kann man herausfinden, wo die .exe-Datei liegt, die ausgeführt wurde?
-
So
char buf[256]; GetModuleFileName(NULL, buf, 255); CString strPfad; strPfad.Format("%s", buf); int nTmp = strPfad.ReverseFind('\\'); strPfad.Delete(nTmp,strPfad.GetLength()-nTmp);oder so
CString strPath = GetCommandLine();/* Pfad + Name der Exe holen*/ int pos = strPath.ReverseFind( '\\'); /* letztes '\' finden*/ strPath = strPath.Mid(1, pos-1); /* Name der Exe abtrennen, so dass nur noch der Pfad übrig bleibt*/
-
Oder kürzer
char htext[MAXPATH]; memset(htext,0,MAXPATH); GetModuleFileName(NULL,htext,MAXPATH); String AktVerz=ExtractFilePath(htext);CString gehört meines Wissens zus MFC und nicht zur VCL
-
Wozu WinAPI.
AnsiString path = ExtractFilePath(Application->ExeName);
-
Hey super, das klappt! Danke