无法从UINT32_T*转换为lpdword
Cannot convert from uint32_t* to LPDWORD
我正在尝试调用Windows API函数GetExitCodeProcess
,该函数将LPDWORD
作为其第二个参数。
根据MSDN,LPDWORD
是指向未签名的32位值的指针。因此,我尝试通过uint32_t*
,但是编译器(MSVC 11.0)对此不满意:
错误c2664:'getExitCodeProcess':无法将参数2从'uint32_t *'转换为'lpdword'
static_cast
也无济于事。这是为什么?在这种情况下,使用reinterpret_cast
安全吗?
来自文档:
dword
一个32位未签名的整数。范围为0至4294967295小数。 此类型在intsafe.h中声明如下:
typedef unsigned long DWORD;
所以,LPDWORD
是unsigned long int*
。但是您正在尝试通过unsigned int*
。我知道类型指向大小相同的变量,但指针类型不兼容。
解决方案是声明类型DWORD
的变量,并传递该变量的地址。这样的东西:
DWORD dwExitCode;
if (!GetExitCodeProcess(hProcess, &dwExitCode))
{
// deal with error
}
uint32_t ExitCode = dwExitCode;
相关文章:
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将 Qvector<uint8_t> 转换为 QString
- 如何在cuSparse中使用cusparseXcoo2csr从coo转换为csc
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中使用nlohmann从类到json的转换
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 复制列表初始化的隐式转换的等级是多少
- 正在将指针转换为范围
- 如何防止 c++ 在从浮点型转换为双精度型(不适用于 IO)时添加额外的小数?
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 无法从UINT32_T*转换为lpdword
- "GetUserNameA":无法将参数 2 从"int"转换为"LPDWORD"
- 无法从'unsigned int *'转换为'LPDWORD'