Private Const WM_MCOMMAND As Integer = &H102 + 200
Private Const FILE_MAP_ALL_ACCESS As Integer = &H1 Or &H2 Or &H4 Or &H8 Or &H10 Or &HF0000
Private Const PAGE_READWRITE As Integer = &H4
Private Const INVALID_HANDLE_VALUE As Integer = -1
Declare Auto Function SendMessage Lib "user32" ( _
ByVal hWnd As IntPtr, _
ByVal Msg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As Integer) As Integer
Private Declare Auto Function CreateFileMapping Lib "kernel32" ( _
ByVal hFile As Integer, _
ByVal lpFileMappingAttributes As Integer, _
ByVal flProtect As Integer, _
ByVal dwMaximumSizeHigh As Integer, _
ByVal dwMaximumSizeLow As Integer, _
ByVal lpName As String) As IntPtr
Declare Function MapViewOfFile Lib "kernel32" Alias "MapViewOfFile" ( _
ByVal hFileMappingObject As IntPtr, _
ByVal dwDesiredAccess As Integer, _
ByVal dwFileOffsetHigh As Integer, _
ByVal dwFileOffsetLow As Integer, _
ByVal dwNumberOfBytesToMap As UIntPtr) As IntPtr
Private Declare Auto Function wsprintf Lib "user32" ( _
ByVal lpOut As IntPtr, _
ByVal lpFmt As String) As Integer
Private Declare Auto Function UnmapViewOfFile Lib "kernel32" ( _
ByVal lpBaseAddress As IntPtr) As Boolean
Public Declare Auto Function CloseHandle Lib "kernel32.dll" ( _
ByVal hObject As IntPtr) As Boolean
Function SendCommand(ByVal hwnd As IntPtr, ByVal command As String) As Boolean
Dim hMapFile As IntPtr
Dim mData As IntPtr
Dim NumberOfBytes As UIntPtr
Dim intWsprintf As Integer
Dim intSendmessage As Integer
' hwnd = 459282
' command = "/msg XBN`grind test"
' Returns: 1684
hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 4096, "mIRC")
' Returns: 72548352
mData = MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, NumberOfBytes)
' Returns: 18
intWsprintf = wsprintf(mData, command)
' Returns: 0
intSendmessage = (SendMessage(hwnd, WM_MCOMMAND, 1, 0))
' Returns: False
UnmapViewOfFile(mData)
' Returns: False
CloseHandle(hMapFile)
Return True
End Function