Reputation: 1024
An unmanaged C++ dll has an exported function, that takes an int type as window hanlde
void SetWindowHandle(int nHandle);
else where in the unmanaged dll code the int
is casted to HWND
and is used properly.
And from the windows forms application, I set the handle as follows
_hHandle = this->Handle.ToInt32();
m_pViewer->SetWindowHandle(_hHandle);
Where _hHandle
is a private member inside the class. Am I getting the handle correctly ?. Seems like it is, but apparently the application doesn't give the desire output. I suspect the problem is with the handle.
PS: I have access to the unmanaged dll so I can make modification in there for any suggested changes.
Upvotes: 1
Views: 2079
Reputation: 1566
Could the issue be related to different copies of the CRT library being used? http://msdn.microsoft.com/en-us/library/ms235460%28v=VS.90%29.aspx
Upvotes: 1
Reputation: 163257
On the face of it, there's nothing wrong. You haven't shown the whole .Net declaration. One thing to watch out for is that the calling conventions need to match. The usual calling convention for DLLs is stdcall, but that's not the default in C++. You have to ask for it, usually by using the WINAPI
macro like you see in all the Windows headers.
Since you have access to both sides of the call, why don't you use the debugger to find out whether you're getting the handle correctly? Either set breakpoints and check the variables' values, or print the values to the debug console or a file and inspect the results.
Upvotes: 1