宽字符的话就用宽字符的函数
#include<windows.h>
#include<stdio.h>
#include<stdlib.h>
void Copyself()
{
wchar_t szSelfName[MAX_PATH] = {0};
wchar_t szWindowsPath[MAX_PATH] = {0};
wchar_t szSystemPath[MAX_PATH] = {0};
wchar_t szTemPath[MAX_PATH] = {0};
GetModuleFileName(NULL, szSelfName, MAX_PATH);
GetWindowsDirectory(szWindowsPath, MAX_PATH);
GetSystemDirectory(szSystemPath, MAX_PATH);
wcscat(szWindowsPath, L"\\test.txt");
wcscat(szSystemPath, L"\\test.txt");
CopyFile(szSelfName, szWindowsPath, FALSE);
CopyFile(szSelfName, szSystemPath, FALSE);
}
void GetSysInfo()
{
wchar_t szComputerName[MAXBYTE] = {0};
wchar_t szUserName[MAXBYTE] = {0};
unsigned long nSize = MAXBYTE;
OSVERSIONINFO OsVER;
OsVER.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OsVER);
if( OsVER.dwOSVersionInfoSize == VER_PLATFORM_WIN32_NT)
{
if(OsVER.dwMajorVersion == 5 && OsVER.dwMajorVersion == 1)
{
printf("Windows xp %s \r\n", OsVER.szCSDVersion);
}
else if(OsVER.dwMajorVersion == 5 && OsVER.dwMajorVersion == 0)
{
printf("Windows 2k \r\n");
}
}
else
{
printf("Other system\r\n");
}
GetComputerName(szComputerName, &nSize);
wprintf(L"Computer Name is %s \r\n", szComputerName);
nSize = MAXBYTE;
GetUserName(szUserName, &nSize);
wprintf(L"User Name is %s \r\n", szUserName);
}
int main()
{
Copyself();
GetSysInfo();
system("pause");
return 0;
}