_NetSend("BossComp", "Проверка связи!", "От Васи Пупкина", "Мого начальника")
If @error Then MsgBox(32, "Не понял", "Начальник в отпуске?")
Func _NetSend($sReceiverComputer, $sMessage, $sSender = "", $sReceiverName = "")
Local $aHandle, $tMessage, $pMessage, $zMessage, $tMailSlot, $pMailSlot
Local $tOVERLAPPED = DllStructCreate("dword;dword;dword;dword;hwnd")
Local $pOVERLAPPED = DllStructGetPtr($tOVERLAPPED), $aErr, $aRet
$tMailSlot = DllStructCreate("char["& StringLen("\\" & $sReceiverComputer & _
"\MAILSLOT\messngr") + 1 & "]")
$pMailSlot = DllStructGetPtr($tMailSlot)
$sMessage = _StringToOEM($sSender) & Chr(0) & _
_StringToOEM($sReceiverName) & Chr(0) & _
_StringToOEM($sMessage) & Chr(0)
$tMessage = DllStructCreate("byte[" & StringLen($sMessage) & "]")
$pMessage = DllStructGetPtr($tMessage)
$zMessage = DllStructGetSize($tMessage)
DllStructSetData($tMailSlot, 1, "\\" & $sReceiverComputer & "\MAILSLOT\messngr")
DllStructSetData($tMessage, 1, $sMessage)
$aHandle = DllCall("kernel32.dll", "hwnd", "CreateFile", _
"ptr",$pMailSlot,"int",0x40000000,"int",1,"ptr",0,"int",0x3,"int",0x80,"int",0)
If $aHandle[0]=0 Then
$aErr = DllCall("kernel32.dll", "int", "GetLastError")
Return SetError(1, $aErr[0], False) ; Ошибка создания файла
EndIf
$aRet = DllCall("kernel32.dll", "int", "WriteFile", _
"hwnd", $aHandle[0], "ptr", $pMessage, "int", 45, "ptr", 0, "ptr", $pOVERLAPPED)
DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $aHandle[0])
If $aRet[0]=0 Then Return SetError(2, 0, False) ; Ошибка записи данных
Return True
EndFunc ;==> _NetSend (v3.3.0.0)
Func _StringToOEM($sText)
Local $sOEM = DllStructCreate("char["& StringLen($sText)+1 &"]")
Local $aRet = DllCall("User32.dll", "int", _
"CharToOem", "str", $sText, "ptr", DllStructGetPtr($sOEM))
If Not(IsArray($aRet)) Then Return SetError(1, 0, '') ; ошибка DLL
If $aRet[0]=0 Then Return SetError(2, $aRet[0], '') ; ошибка функции
Return DllStructGetData($sOEM, 1)
EndFunc ;==> _StringToOEM (v3.3.0.0)