/* apppath.d Shows how to find the path of the current executable. (Windows-only) */ import std.c.windows.windows; import std.c.stdio; import std.string; extern(C) int strlen(char* c); extern(Windows) { DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize); HMODULE GetModuleHandleA(LPCSTR lpModuleName); } char[] AppExePath() { /* returns the Path to the current .exe module (e.g. "F:\PGM\D\TRAYICON\") */ char[] strtmp; strtmp[].length = 1024; GetModuleFileNameA(GetModuleHandleA(null), cast(char*) strtmp, 1024); int j = rfind(strtmp[0..strlen(strtmp)], "\\"); strtmp = strtmp[0..j+1]; return strtmp; } void main() { printf("%.*s\n", AppExePath); }