Passing function pointer from VB .NET to C dll

  • Thread starter Thread starter kevin
  • Start date Start date
K

kevin

Does any one know how to pass a function pointer as a function parameter
from VB .NET to a C dll?



Currently I'm passing it this way

Public Delegate Sub DSCUserInterruptFunction()

Public Declare Function dscUserInt Lib "dscud.dll" (ByVal board As Short,
ByRef dscuserint As dscUserInt, <MarshalAs(UnmanagedType.FunctionPtr)> ByRef
functions As DSCUserInterruptFunction) As Byte

Public Sub count()

dscUserInt(board, dscuserint, AddressOf count)

But this isn't working. My program just crashes and exits. Any ideas?
 
Hi,

Use a delegate.
http://msdn.microsoft.com/library/d.../cpguide/html/cpconusingcallbackfunctions.asp

Ken
-----------------
Does any one know how to pass a function pointer as a function parameter
from VB .NET to a C dll?



Currently I'm passing it this way

Public Delegate Sub DSCUserInterruptFunction()

Public Declare Function dscUserInt Lib "dscud.dll" (ByVal board As Short,
ByRef dscuserint As dscUserInt, <MarshalAs(UnmanagedType.FunctionPtr)> ByRef
functions As DSCUserInterruptFunction) As Byte

Public Sub count()

dscUserInt(board, dscuserint, AddressOf count)

But this isn't working. My program just crashes and exits. Any ideas?
 
Back
Top