I'm trying to call the Windows API function GetExitCodeProcess which takes a LPDWORD as its second parameter.
According to MSDN, LPDWORD is a pointer to an unsigned 32-bit value. So I tried to pass a uint32_t*, but the compiler (MSVC 11.0) is not happy with it:
error C2664: 'GetExitCodeProcess' : cannot convert parameter 2 from 'uint32_t *' to 'LPDWORD'
Also a static_cast does not help. Why is that? And is it safe to use a reinterpret_cast in this case?
From the documentation:
DWORD
A 32-bit unsigned integer. The range is 0 through 4294967295 decimal. This type is declared in IntSafe.h as follows:
typedef unsigned long DWORD;
So, LPDWORD is unsigned long int*. But you are trying to pass unsigned int*. I know that the types point to variables that are the same size, but the pointer types are not compatible.
The solution is to declare a variable of type DWORD, and pass the address of that variable. Something like this:
DWORD dwExitCode;
if (!GetExitCodeProcess(hProcess, &dwExitCode))
{
// deal with error
}
uint32_t ExitCode = dwExitCode;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With