VC獲取本機計算機名

#include "stdafx.h"
#include "windows.h"
#include "string"

using namespace std;


     wstring myComputerName(   )
{
   TCHAR szHostName[200];
   DWORD dwSize   =   200;
   GetComputerName(   szHostName,   &dwSize   );
   return wstring( szHostName);
}
int _tmain(int argc, _TCHAR* argv[])
{

setlocale(LC_ALL ,"chs");
    wstring w = myComputerName();
wprintf( L"%s/n", w.c_str());
getchar();

return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章