K
Ken Varn
I have a managed C++ function that accepts an IntPtr argument. I am passing
in a variable of type HANDLE for the IntPtr argument. The compiler does not
issue any warnings for this, so I am assuming it is ok (maybe this is a bad
assumption). Anyhow, for some reason, the IntPtr is not set to the same
value that was passed in by HANDLE. It seems as though the type conversion
is not being done correctly. Here is the example:
void MyFunc(IntPtr Val)
{
IntPtr MyVal = Val;
}
void CallMyFunc()
{
HANDLE Test = NULL;
MyFunc(Test);
}
When this code is run, the value of MyVal appears to be getting set to the
pointer to Test rather than its value (NULL). Is this supposed to work this
way? Since HANDLE's typedef is void *, I am not sure why this is happening.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------
in a variable of type HANDLE for the IntPtr argument. The compiler does not
issue any warnings for this, so I am assuming it is ok (maybe this is a bad
assumption). Anyhow, for some reason, the IntPtr is not set to the same
value that was passed in by HANDLE. It seems as though the type conversion
is not being done correctly. Here is the example:
void MyFunc(IntPtr Val)
{
IntPtr MyVal = Val;
}
void CallMyFunc()
{
HANDLE Test = NULL;
MyFunc(Test);
}
When this code is run, the value of MyVal appears to be getting set to the
pointer to Test rather than its value (NULL). Is this supposed to work this
way? Since HANDLE's typedef is void *, I am not sure why this is happening.
--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.
EmailID = varnk
Domain = Diebold.com
-----------------------------------