1 HMODULE GetSelfModuleHandle() 2 { 3 MEMORY_BASIC_INFORMATION mbi; 4 return ((::VirtualQuery(GetSelfModuleHandle, &mbi, sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL); 5 } 6 7 extern string GetCurrentDllPath(void) 8 { 9 TCHAR path[MAX_PATH] = {0}; 10 memset(path, 0, sizeof(path)); 11 GetModuleFileName(GetSelfModuleHandle(),path,sizeof(path)); 12 int l = _tcslen(path); 13 char driveA[1024] = {0}; 14 char drive[_MAX_DRIVE] = {0}; 15 char dir[_MAX_DIR] = {0}; 16 char fname[_MAX_FNAME] = {0}; 17 char ext[_MAX_EXT] = {0}; 18 int length = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL); 19 WideCharToMultiByte(CP_ACP, 0, path, -1, driveA, length, NULL, NULL); 20 _splitpath(driveA,drive ,dir ,fname ,ext); 21 string olddrive = drive; 22 string olddir = dir; 23 string str = olddrive + olddir; 24 return str; 25 }