ttp://dobon.net/vb/bbs/log3-8/4379.html にも同様の質問があったため、上記ページ等を参考にして 以下のように作成いたしました。 --- Delegate Sub SampleDelegate() Public Class sampleClass Public Sub Method() MsgBox("Method") End Sub End Class
Private Declare Function WriteFileEx Lib "kernel32" (ByVal hFile As Integer, ByVal lpBuffer As String, ByVal lpNumberOfBytesWritten As Integer, ByVal lpOverlapped As Integer, ByVal lpCompletionRoutine As SampleDelegate) As Integer
Dim instance As New SampleClass ' こちらは成功する ' bool = WriteFile(pipe, "ABCDEFG", 8, size, 0) bool = WriteFileEx(pipe, "ABCDEFG", 8, 0, AddressOf instance.Method) --- 実行しますとWriteFileExでSystem.NullReferenceExceptionが発生いたします。