|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Delegate problemsThe only 'AddressOf' examples dealing with a delegate for a Function do not show the original Function in question. The following is my attempt which fails. Delegate Function DeviceAttachDelegate(ByVal hDevice As Integer, ByRef pDeviceInfo As WDU_DEVICE, _ ByRef pUserData As DEVICE_CONTEXT) As Integer Public Function DeviceAttach(ByVal hDevice As Integer, ByRef pDeviceInfo As WDU_DEVICE, _ ByRef pUserData As DEVICE_CONTEXT) As Boolean The DeviceAttach ( and DeviceDetach) function is a callback from a 3rd party dll so must be exact. To set up the callback address it must be presented to an API call as an Integer address (Yep, worked in VB6) Public Sub SetEventTable(ByRef eventTable As WDU_EVENT_TABLE) eventTable.pfDeviceAttach = AddressOf DeviceAttach eventTable.pfDeviceDetach = AddressOf DeviceDetach End Sub and the error shown is 'AddressOf' expression cannot be converted to 'Integer' because 'Integer' is not a delegate type. It's obvious I'm doing something way wrong. Probably need some pinvoke type stuff. I would appreciate some guidance here. GalenS It looks like you are trying to use C# syntax with VB.Net
try instead, Addhandler eventTable.pfDeviceAttach, addressof DeviceAttach hth, Alan.
Show quote
Hide quote
"AlanT" <alanto***@users.com> wrote in message That doesn't work as eventTable is not really a series of events. It's a news:1144778316.285253.283370@e56g2000cwe.googlegroups.com... > > It looks like you are trying to use C# syntax with VB.Net > > try instead, > > > Addhandler eventTable.pfDeviceAttach, addressof DeviceAttach > > > hth, > Alan. > series of addresses the dll will use when it does it's callback event. GalenS Hi,
Based on my understanding, you are going to P/Invoke into an unmanaged dll and pass the managed code as a callback function. If I misunderstood, please feel free let me know. Here are two links for your reference. How to set a hook in Visual Basic .NET http://support.microsoft.com/?id=319524 Managing Low-Level Keyboard Hooks with the Windows API for VB .NET http://www.codeguru.com/vb/gen/vb_system/keyboard/article.php/c4831/ If you still have any concern, please feel free to post here. Best regards, Peter Huang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. After much thought, I am dropping my attempt to use unmanaged API calls
entirely. Instead I am going to make a VB6 Activex dll that does all the work. Then NET only has to supply a few variables and the dll will do the work. My app uses a USB connection to our device. It is USB 2.0 because we need the speed. The 3rd party USB drivers were recently upgraded to NET. The problem is, the original version runs 54 times faster than the NET version. GalenS Show quoteHide quote ""Peter Huang" [MSFT]" <v-phu***@online.microsoft.com> wrote in message news:LI3Q0NgXGHA.888@TK2MSFTNGXA01.phx.gbl... > Hi, > > Based on my understanding, you are going to P/Invoke into an unmanaged dll > and pass the managed code as a callback function. > > If I misunderstood, please feel free let me know. > > Here are two links for your reference. > > How to set a hook in Visual Basic .NET > http://support.microsoft.com/?id=319524 > > Managing Low-Level Keyboard Hooks with the Windows API for VB .NET > http://www.codeguru.com/vb/gen/vb_system/keyboard/article.php/c4831/ > > If you still have any concern, please feel free to post here. > > Best regards, > > Peter Huang > > Microsoft Online Community Support > ================================================== > When responding to posts, please "Reply to Group" via your newsreader so > that others may learn and benefit from your issue. > ================================================== > This posting is provided "AS IS" with no warranties, and confers no > rights. > Hi Galen,
Thanks for your feedback. If you still have any concern, please feel free to post here. Best regards, Peter Huang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
MSDN-Example with Collection(of T)
Saving Jpeg/Exif info Please Help. Total VB.Net newbie - Directory.Exists question How do I find and use a Window Handle? "Looksalike" algorithm How to simplifying boolean algebra expression? How to simplifying boolean algebra expression? Error connectiong to database Reading block of text from file Simple question |
|||||||||||||||||||||||