15-08-17, 04:54 PM
الكود كاملا بعد كتابته علي هيئة دوال
PHP كود :
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim ptr As IntPtr = CallBackToIntPtr()
Me.Text = IntPtrToCallBack(ptr, "any file name")
End Sub
Private Function CallBackToIntPtr() As IntPtr
Dim delegateParams As IsFielExists = New IsFielExists(AddressOf IO.File.Exists)
Dim ptr As IntPtr = IntPtr.Zero
If delegateParams IsNot Nothing Then
ptr = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(delegateParams)
End If
Return ptr
End Function
Private Function IntPtrToCallBack(ptr As IntPtr, s As String) As Boolean
Dim result As IsFielExists = Nothing
If ptr <> IntPtr.Zero Then
Dim delegateParams As IsFielExists = New IsFielExists(AddressOf IO.File.Exists)
Dim t As Type = delegateParams.GetType
result = System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(ptr, t)
End If
Return result(s)
End Function
Public Delegate Function IsFielExists(FilePath As String) As Boolean
End Class
Retired

