hello,
I need some help getting a callback from a com object written in c+ to work
All I get now is 'The specified cast is not valid'. My code is
Imports System.Runtime.InteropServices
Module Module1
Public Delegate Function CallBackDelegate(ByVal e As Long, ByVal param As Integer, ByVal objectName As IntPtr, ByVal testName As IntPtr, ByVal objectID As Long)
' below if the function as is appears in C
'CALLBACK_RESULT clbk_fn (unsigned long Event,
' unsigned int Param,
' const char *ObjectName,
' const char *VirusName,
' unsigned long ObjectID)
Sub Main()
Dim VirusScanner As New IKAVELib.KAVE
Try
VirusScanner.InitializeW(vbNull, vbNull, New CallBackDelegate(AddressOf CallBackHandler))
Catch
Debug.WriteLine(Err.Description)
Finally
VirusScanner = Nothing
End Try
End Sub
Private Function CallBackHandler(ByVal e As Long, ByVal param As Integer, ByVal objectName As IntPtr, ByVal testName As IntPtr, ByVal objectID As Long)
' Private Function CallBackHandler(ByVal e As UInt32, ByVal param As UInt16, ByVal objectName As String, ByVal testName As String, ByVal objectID As UInt32) As IKAVELib.KAVE
'ByVal e As Long, ByVal param As Integer, ByVal objectName As IntPtr, ByVal testName As intptr, ByVal objectID As lon
Console.WriteLine("got here")
End Function
End Module
I've changed the function variable types to see if it made any difference. They were as per the c example previously with UInt's etc.
The software always fails at the initialise function. The dll is referenced and properly registered on the system.
If anyone has any suggestions, that'd be great
Thanks.
I need some help getting a callback from a com object written in c+ to work
All I get now is 'The specified cast is not valid'. My code is
Imports System.Runtime.InteropServices
Module Module1
Public Delegate Function CallBackDelegate(ByVal e As Long, ByVal param As Integer, ByVal objectName As IntPtr, ByVal testName As IntPtr, ByVal objectID As Long)
' below if the function as is appears in C
'CALLBACK_RESULT clbk_fn (unsigned long Event,
' unsigned int Param,
' const char *ObjectName,
' const char *VirusName,
' unsigned long ObjectID)
Sub Main()
Dim VirusScanner As New IKAVELib.KAVE
Try
VirusScanner.InitializeW(vbNull, vbNull, New CallBackDelegate(AddressOf CallBackHandler))
Catch
Debug.WriteLine(Err.Description)
Finally
VirusScanner = Nothing
End Try
End Sub
Private Function CallBackHandler(ByVal e As Long, ByVal param As Integer, ByVal objectName As IntPtr, ByVal testName As IntPtr, ByVal objectID As Long)
' Private Function CallBackHandler(ByVal e As UInt32, ByVal param As UInt16, ByVal objectName As String, ByVal testName As String, ByVal objectID As UInt32) As IKAVELib.KAVE
'ByVal e As Long, ByVal param As Integer, ByVal objectName As IntPtr, ByVal testName As intptr, ByVal objectID As lon
Console.WriteLine("got here")
End Function
End Module
I've changed the function variable types to see if it made any difference. They were as per the c example previously with UInt's etc.
The software always fails at the initialise function. The dll is referenced and properly registered on the system.
If anyone has any suggestions, that'd be great
Thanks.