My aplication name
-
Hi everybody.How can i get the entire path of an aplication when its excecuted??. For example, when the user runs my aplication, i want in the WM_CREATE message, call the function GetAppName created by my and get C:\....\myApp.exe
CString GetExePath() { CString str; TCHAR szEXEPath[MAX_PATH]; GetModuleFileName ( NULL, szEXEPath, MAX_PATH ); str = szEXEPath; CString s1,s3; int pos = str.ReverseFind( '\\' ); CString s2; s2 = str.Left( pos+1 ); return s2; }
This should get you started.
-
CString GetExePath() { CString str; TCHAR szEXEPath[MAX_PATH]; GetModuleFileName ( NULL, szEXEPath, MAX_PATH ); str = szEXEPath; CString s1,s3; int pos = str.ReverseFind( '\\' ); CString s2; s2 = str.Left( pos+1 ); return s2; }
This should get you started.
-
No problem good luck coding.
-
Hi everybody.How can i get the entire path of an aplication when its excecuted??. For example, when the user runs my aplication, i want in the WM_CREATE message, call the function GetAppName created by my and get C:\....\myApp.exe
While smesser's technique works (using the reversefind), I prefer using the _splithpath so here's an alternative:
TCHAR buff[MAX_PATH];
GetModuleFileName(NULL, buff, MAX_PATH);char drive[2];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
_splitpath(buff, drive, dir, fname, ext);