我正在尝试使用API中的一些C代码(它不喜欢C++编译器),但我遇到了一些麻烦。我有这样的代码:
// send the request (allow up to 9 tries)
while ((++i < 10) && !SendMessageTimeout(
m_hWnd, // FS6 window handle
m_msg, // our registered message id
m_atom, // wParam: name of file-mapping object
0, // lParam: offset of request into file-mapping obj
SMTO_BLOCK, // halt this thread until we get a response
2000, // time out interval
&dwError)) // return value || dwError is a DWORD
{ Sleep(100); // Allow for things to happen
}它返回一个错误(我正在使用):
error: C2664: 'LRESULT SendMessageTimeoutW(HWND,UINT,WPARAM,LPARAM,UINT,UINT,PDWORD_PTR)' : cannot convert argument 7 from 'DWORD *' to 'PDWORD_PTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast我没有使用DWORD和PDWORD_PTRs的经验,所以我不太明白这一点。任何帮助都是非常感谢的。如果您需要查看更多的代码,请告诉我,但我认为这是相关的。
发布于 2014-07-21 20:51:27
dwError需要是DWORD_PTR,而不是DWORD。
请注意,DWORD_PTR并不意味着“指向DWORD的指针”,而是“至少与指针一样大的DWORD”。
发布于 2014-07-21 20:51:24
PTR
https://stackoverflow.com/questions/24874435
复制相似问题