-
November 27th, 2008, 01:01 AM
#1
Need help, handling C++ dll in vb.net
Hi everyone,
I'm using visual studio 2005 and i'm using a third party C++ dll which cannot be directly added as reference in my project.... A sample project made in C++ has been provided together with the SDK, however the project i'm doing needs to be in vb.net.
In the dll i'm using there is a method called BioDRV_Enroll which is declared as DWORD BioDRV_Enroll(hWnd, lpReserved)
HWND hWnd <---- Window handle to receive the completion message.
LPVOID lpReserved <----Reserved(null must be set)
This method should return a message know as BIODRV_COMPLETE_ENROLL
and together with that is a WPARAM and LPARAM...
my problem is how to declare it in VB or VB.net for that matter and access those return message after i invoke the function..
Any help would be greatly appreciated as i am new to this programming language..
Thanks and Regards,
ByVal
-
November 27th, 2008, 04:17 AM
#2
Re: Need help, handling C++ dll in vb.net
Hello ByVal,
Welcome to codeguru
This is how I declare the PostMessage function in user32.dll:
Code:
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Public Function PostMessage( _
ByVal hWnd As IntPtr, _
ByVal Msg As UInteger, _
ByVal wParam As IntPtr, _
ByVal lParam As IntPtr) As Boolean
End Function
Hope it helps
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010
-
November 27th, 2008, 09:48 PM
#3
Re: Need help, handling C++ dll in vb.net
Hi HairyMonkeyMay,
Thanks for the quick response.
Currently this is how i declare the method
Code:
Private Declare Function BioDRV_Enroll Lib "FvidDrv.dll" (ByVal HWND As Long, ByVal LPVOID As IntPtr) As Short
and i have a method that uses the function that looks like this
Code:
Private Function Enroll() As Boolean
Dim s As Long = BioDRV_Enroll(Me.Handle.ToInt32, Nothing)
If s <> 0
Return False
End If
Return True
End Function
It properly returns the correct value...as for this function a zero which signifies a normal exit...
however this is an asynchronous-type function and its completion is judged by the completion message called BIODRV_COMPLET_ENROLL.
The message reports the completion of the function above and it also has a WPARAM and LPARAM that accompanies the message...
my problem is on how to manipulate this WPARAM and LPARAM as i need to control them to get the returned handle to proceed with other processes.
Thanks in advance for your help...and i certainly thank you for the code snippet you gave, looks like that's how a true .net declaration is done.
Thanks and Regards,
ByVal
-
November 29th, 2008, 01:07 PM
#4
Re: Need help, handling C++ dll in vb.net
Sounds like you need to create a DELAGATE to handle the external condition
-
November 30th, 2008, 10:06 PM
#5
Re: Need help, handling C++ dll in vb.net
Originally Posted by dglienna
Sounds like you need to create a DELAGATE to handle the external condition
Hi dglienna,
You mentioned delegate, would it allow me to control an unmanaged dll directly in my vb.net project? my fear is that I would have to create another dll to handle all messages that is returned by the current dll, which is additional hassle.....if it is possible to handle this wparam and lparam using delegate in vb.net how can i go about with this? thank you very much for your time.
Thanks and Regards,
ByVal
-
December 1st, 2008, 01:41 PM
#6
Re: Need help, handling C++ dll in vb.net
I'm not sure, but you can take a look at this (and other) code:
http://www.codeproject.com/KB/vb/Delegate.aspx
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|