|
#define _WINSOCK_DEPRECATED_NO_WARNINGS 1
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <stdio.h>
#include <windows.h>
#include <string>
#include <string.h>
using namespace std;
int main()
{
WCHAR PCName[255];//直接使用wchar类型定义
WCHAR UserName[255];
unsigned long size = 255;
GetComputerName(PCName, &size);//GetComputerName()函数的第一个参数的类型是LPWSTR,所以直接使用wchar定义前面的数组
GetUserName(UserName, &size);//GetUserName()函数同上
printf("The computer's name is :%S\n", PCName);//打印要用%S,对应wchar
printf("The computer's user name is %S\n", UserName);
system("pause");
return 0;
} |
|