Forum: VB.NET |
Thema:
Re: AddressOf bei VB.Net |
Von:
Tobi Ulm (
08.12.2004 14:12) |
Hi Harald,
hier ein bisschen Code:
TestCallBack exported von PinvokeLib.dll.
TestCallBack2 exported von PinvokeLib.dll.
Public Delegate Function FPtr( ByVal value As Integer ) As Boolean
Public Delegate Function FPtr2( ByVal value As String ) As Boolean
Public Class LibWrap
' Declares managed prototypes for unmanaged functions.
Declare Sub TestCallBack Lib "..\LIB\PinvokeLib.dll" ( ByVal cb _
As FPtr, ByVal value As Integer )
Declare Sub TestCallBack2 Lib "..\LIB\PinvokeLib.dll" ( ByVal cb2 _
As FPtr2, ByVal value As String )
End Class 'LibWrap
Public Class App
Public Shared Sub Main()
Dim cb As FPtr
cb = AddressOf App.DoSomething
Dim cb2 As FPtr2
cb2 = AddressOf App.DoSomething2
LibWrap.TestCallBack( cb, 99 )
LibWrap.TestCallBack2( cb2, "abc" )
End Sub 'Main
Public Shared Function DoSomething( ByVal value As Integer ) As Boolean
Console.WriteLine( ControlChars.CrLf + "Callback called with _
param: {0}", value )
...
End Function 'DoSomething
Public Shared Function DoSomething2( ByVal value As String ) As Boolean
Console.WriteLine( ControlChars.CrLf + "Callback called with _
param: {0}", value )
...
End Function 'DoSomething2
End Class 'App
cu
Tobi
cu
Tobi
Antworten
Vorsicht bei der Eingabe: Die Zeichen ' oder -- sind nicht erlaubt!