BOOLEAN WINAPI GetUserNameEx(
__in EXTENDED_NAME_FORMAT NameFormat,
__out LPTSTR lpNameBuffer,
__in_out PULONG lpnSize
);
Header
Declared in Secext.h; include Security.h.
Library
Use Secur32.lib.
头文件添加:
#include "Security.h"
#pragma comment(lib,"Secur32.lib")
C:\WinDDK\7600.16385.1\inc\api\sspi.h(60) : fatal error C1189: #error : You must define one of SECURITY_WIN32, SECURITY_KERNEL, or
编译这个出现这个错误提示。
在头文件处,添加 如下定义:
#define SECURITY_WIN32
WCHAR wzUser[MAX_PATH] = {0};
ULONG ulSize;
GetUserNameEx(NameUserPrincipal,wzUser,&ulSize);