Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ ';GetUserNameA';:无法将参数2从';int';至';LPDWORD&x27;_C++ - Fatal编程技术网

C++ ';GetUserNameA';:无法将参数2从';int';至';LPDWORD&x27;

C++ ';GetUserNameA';:无法将参数2从';int';至';LPDWORD&x27;,c++,C++,我试过了 #包括 #包括 字符用户名[UNLEN+1]; GetUserName(用户名,UNLEN+1); 但是我遇到了这个错误:“GetUserNameA”:无法将参数2从“int”转换为“LPDWORD”根据,传入的长度必须是指向双字的指针,因为函数会根据返回的内容对其进行更改 因此,您应该有如下内容: TCHAR username[UNLEN+1]; // TCHAR to allow for MBCS and Unicode DWORD len = UNLEN + 1;

我试过了

#包括
#包括
字符用户名[UNLEN+1];
GetUserName(用户名,UNLEN+1);

但是我遇到了这个错误:“GetUserNameA”:无法将参数2从“int”转换为“LPDWORD”

根据,传入的长度必须是指向双字的指针,因为函数会根据返回的内容对其进行更改

因此,您应该有如下内容:

TCHAR username[UNLEN+1];       // TCHAR to allow for MBCS and Unicode
DWORD len = UNLEN + 1;         //   if you're in to that sort of thing :-)
GetUserName(username, &len);

根据,传入的长度必须是指向双字的指针,因为函数会根据返回的内容对其进行更改

因此,您应该有如下内容:

TCHAR username[UNLEN+1];       // TCHAR to allow for MBCS and Unicode
DWORD len = UNLEN + 1;         //   if you're in to that sort of thing :-)
GetUserName(username, &len);

类型
LPDWORD
实际上是一个指针

您需要执行以下操作:

char username[UNLEN + 1];
DWORD name_length = ULEN + 1;
GetUserName(username, &name_length);

类型
LPDWORD
实际上是一个指针

您需要执行以下操作:

char username[UNLEN + 1];
DWORD name_length = ULEN + 1;
GetUserName(username, &name_length);

阅读下面的内容。这是一个输入和输出参数。请阅读。这是一个输入和输出参数。在找到要包含的文档链接(以及这些文档的引用)之前,我必须停止保留答案:-)每次都让我慢下来。我必须学会先发布答案,然后再编辑以添加链接。:-)“您传入的长度必须是指向双字的指针”,其中说明您应该在我的文本中的“指针”一词中以及MSDN上的类型定义
LPDWORD
(指向双字的长指针)中写入“&len”@user10056
&len
表示(指向)
len
的地址。在找到要包含的文档链接(以及这些文档的引用)之前,我必须停止保留答案:-)每次都让我慢下来。我必须学会先发布答案,然后再编辑以添加链接。:-)“您传入的长度必须是指向双字的指针”,其中说明您应该在我的文本中的“指针”一词中以及MSDN上的类型定义
LPDWORD
(指向双字的长指针)中写入“&len”@user10056
&len
是指(指向)
len
“类型LPDWORD实际上是一个指针”的地址。说明在哪里?
typedef无符号长DWORD,*PDWORD,*LPDWORD
LPWORD前面的*使其成为指针。“类型LPDWORD实际上是一个指针。”说明在哪里?
typedef无符号长DWORD,*PDWORD,*LPDWORD
LPWORD前面的*使其成为指针。