#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
CHAR szCurrentDirectory[MAX_PATH];
CHAR szMoudlePath[MAX_PATH];
CHAR szMoudlePath1[MAX_PATH];
LPSTR szKerne132 = "kernel32.dll";
HMODULE hKerne132;
DWORD dwCurDirPathLen;
dwCurDirPathLen = GetCurrentDirectory(MAX_PATH,szCurrentDirectory);
if (dwCurDirPathLen == 0)
{
cout << "获取当前目录错误。" << endl;
return 0;
}
cout << "进程当前目录为:" << szCurrentDirectory << endl;
lstrcpy(szCurrentDirectory,"f:\\");
if (!SetCurrentDirectory(szCurrentDirectory))
{
cout << "设置当前目录错误。" << endl;
return 0;
}
cout << "已经设置当前目录为" << szCurrentDirectory << endl;
CreateDirectory("测试",NULL);
dwCurDirPathLen = GetCurrentDirectory(MAX_PATH,szCurrentDirectory);
if (dwCurDirPathLen == 0)
{
cout << "获取当前目录错误。" << endl;
return 0;
}
cout << "GetCurrentDirectory获取当前目录:" << szCurrentDirectory << endl;
if (!GetModuleFileName(NULL,szMoudlePath,MAX_PATH))
{
cout << "获取模块路径录错误。" << endl;
return 0;
}
cout << "本模块路径" << szMoudlePath << endl;
hKerne132 = LoadLibrary(szKerne132);
if (!GetModuleFileName(hKerne132,szMoudlePath1,MAX_PATH))
{
cout << "获取模板块路径错误。" << endl;
return 0;
}
cout << "Kerne132模块路径" << szMoudlePath1 << endl;
return 0;
}