1.爲了保險,要使用GetModuleFileName 而不要使用GetCurrentDirectory,因爲後者的程序如果是通過快捷方式啓動的,則得到的路徑是快捷方式的!!
#include <windows.h>
char szExePath[300];
//得到當前文件路徑名
GetModuleFileName(NULL,szExePath,200);
(strrchr(szExePath, '\\'))[1] = 0;
1.爲了保險,要使用GetModuleFileName 而不要使用GetCurrentDirectory,因爲後者的程序如果是通過快捷方式啓動的,則得到的路徑是快捷方式的!!
#include <windows.h>
char szExePath[300];
//得到當前文件路徑名
GetModuleFileName(NULL,szExePath,200);
(strrchr(szExePath, '\\'))[1] = 0;