C++编译成功,却不不显示正确的结果,帮忙看看错在哪了。谢谢大家!
程序代码:
#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); strcat((char*)szWindowsPath, "\\test.txt"); strcat((char*)szSystemPath, "\\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("Ohter system\r\n"); } GetComputerName(szComputerName, &nSize); printf("Computer Name is %s \r\n", szComputerName); nSize = MAXBYTE; GetUserName(szUserName, &nSize); printf("User Name is %s \r\n", szUserName); } int main() { void Copyself(); void GetSysInfo(); system("pause"); return 0; }
我是在win7下用VS2012编译的。。。。