Passing function pointer from VB .NET to C dll

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

kevin

This is a repost with an update

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?
Thanks.
 
Another related question

How do I keep the garbage collector from collecting the AddressOf count or
my funct variable below?

dim func as DSCUserIntFunction

func = AddressOf count

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top