Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Problem with API, Need help

I got a C++ function in a dll file:

int Initialization (Int PortNum, HWND hWnd, HINSTANCE HInst) as integer

HWND = Main window in the program using the dll
HINSTANCE = Instance in program using the dll

how can i include this function in VB.NET?? Is the following declaration correct?

<DLLImport ("DllName.dll")> Public Shared Function Initialization(ByVal PortNum As Integer, ByVal HWND as IntPtr, ByVal HInst as Int32)

If the declaration above is correct, how can i get the HWND and HINST in vb.net? Can i use:

Dim HWND As IntPtr = Me.Handle

How bout HInstance?? What is HInstance?
Hope somebody can help, thanks!
[695 byte] By [eddom] at [2007-11-11 8:16:16]
# 1 Re: Problem with API, Need help
Your code looks correct, and you may pass the form's .Handle property for the hWnd parameter. For the hInst, pass AppDomain.GetCurrentThreadId.
Phil Weber at 2007-11-11 21:47:51 >
# 2 Re: Problem with API, Need help
Thanks you so much, solved another problem, haha
eddom at 2007-11-11 21:48:46 >