この例では、user32.dll の SendMessage DLL 関数を呼び出して、フィールドに「hello world!」というテキストを書き出します。
DLL の宣言:
// VB .NET code <Dll("user32.dll")> Public Interface IUserDll32Functions Function SendMessageW( _ ByVal obj As TestObject,ByVal message As Integer,ByVal wParam As Integer,ByVal lParam As String) As Integer End Interface
// VB .NET code Public Sub Main() Dim user32Functions As IUserDll32Functions = DllCall.CreateInProcessDllCall(Of IUserDll32Functions)() Dim textField = _desktop.Window().TextField() user32Functions.SendMessageW(textField, WindowsMessages.WM_SETTEXT, 0, "my text") End Sub
// VB .NET code Public Sub Main() Dim user32Functions As IUserDll32Functions = DllCall.CreateAgentDllCall(Of IUserDll32Functions)() Dim textField = _desktop.Window().TextField() user32Functions.SendMessageW(textField, WindowsMessages.WM_SETTEXT, 0, "my text") End Sub