Текущий архив: 2004.04.25;
Скачать: CL | DM;
Вниз
Поблема с NetMessageBufferSend Найти похожие ветки
← →
sucer (2004-02-27 14:15) [0]Отправляю сообщение по локальной сети функцией
NetMessageBufferSend.ВСЕ РАБОТАЕТ, НО ЕСЛИ указать
ip адресс которого сейчас нет в сети(компьютер с таким ip выключен или вообще такого адресса нет), то программа "задумываеться" приблизительно на 10 секунд.
Как сделать чтобы она "не задумывалась"(выполнила функцию и не ждала результата).Может есть подобная другая функция,подскажите кто знает?
Отправляю сообщения в WINXP и WIN2000
----------------------------------------------------------
procedure TfrmNetSend.Button1Click(Sender: TObject);
var
PWSInfo: Pointer;
buflen,SIze: DWORD;
theText:string;
theRemoteHostName: String;
theLocalHostName: String;
msgname: LPWSTR;
fromname: LPWSTR;
buf: Pointer;
begin
TheText:="OnlyTest click";
TheRemoteHostName:="192.168.1.59";
theLocalHostName:="IZVINI ADRESA NET";
{-KOMU-}
Size:=SizeOf(WideChar)*Length(theRemoteHostName)+1; //+1 ?? 0
msgname:=LPWSTR(GetMemory(Size));
StringToWideChar(theRemoteHostName,msgname,Size);//???????? ??? ????? ?
{-SOOBJENIE-}
Size:=SizeOf(WideChar)*Length(theText)+1; //+1 ?? 0
buf:=LPWSTR(GetMemory(Size));
StringToWideChar(theText,buf,Size);//???????? ????? ? UNICODE
{-OT KOGO- //MOJNO NUL}
Size:=SizeOf(WideChar)*Length(theLocalHostName)+1; //+1 ?? 0
fromname:=LPWSTR(GetMemory(Size));
StringToWideChar(theLocalHostName,fromname,Size);//???????? ??? ????? ?
buflen:=DWORD(SizeOf(WideChar)*Length(theText)+1);
NetMessageBufferSend(
nil{servername},
msgname,
fromname{nil fromname},
buf,{?????????}
buflen);
end;
----------------------------------------------------------------
The NetMessageBufferSend function sends a buffer of information to a registered message alias.
Security Requirements
No special group membership is required to execute NetMessageBufferSend on a LAN Manager or Windows NT system. Admin, Accounts, Print, or Server operator group membership is required to successfully execute NetMessageBufferSend on a remote server.
NET_API_STATUS NetMessageBufferSend(
LPTSTR servername,
LPTSTR msgname,
LPTSTR fromname,
LPBYTE buf,
DWORD buflen
);
Parameters
servername
Pointer to a Unicode string containing the name of the remote server on which the function is to execute. A NULL pointer or string specifies the local computer.
msgname
Pointer to a Unicode string containing the message name to which the message buffer should be sent.
fromname
Pointer to a Unicode string containing the message name sending the information. The fromname parameter is new for Windows networking. This parameter is needed for sending interrupting messages from the computer name rather than the logged on user. If NULL is specified, the message is sent from the logged-on user as with LAN Manager 2.x.
buf
Pointer to a buffer of message text.
buflen
The length, in bytes, of the message text in buf.
← →
Rouse_ © (2004-02-27 14:18) [1]Отправляй в отдельном потоке.
Или используй отпавку на mailslot "\\имя\mailslot\messengr"
← →
sucer (2004-02-27 14:30) [2]"в отдельном потоке" - не подойдет,потому что моя программа отправляет сообщения на несколько десятков компьютеров.
"отпавку на mailslot "\\имя\mailslot\messengr"" - поясните пожалуста по подробнее(небольшой кусок кода) как это делать?Я не понимаю...
← →
Rouse_ © (2004-02-27 15:40) [3]Что-то вроде этого
procedure TForm1.Button1Click(Sender: TObject);
var
MSHandle: THandle;
MSMessage: array [0..2] of String;
ResultMsMessage: String;
MSWrite: DWORD;
ServerName: String;
begin
ServerName := Edit1.Text;
if ServerName = "" then ServerName := "*\";
if ServerName[Length(ServerName)] <> "\" then ServerName := ServerName + "\";
MSHandle := CreateFile(PChar("\\" + ServerName + "mailslot\messngr"),
GENERIC_WRITE,// or GENERIC_READ,
FILE_SHARE_READ,
nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
if not Win32Check(MSHandle <> INVALID_HANDLE_VALUE) then Exit;
MSMessage[0] := Edit2.Text;
MSMessage[1] := Edit3.Text;
MSMessage[2] := Memo1.Text;
CharToOem(PChar(MSMessage[0]), PChar(MSMessage[0]));
CharToOem(PChar(MSMessage[1]), PChar(MSMessage[1]));
CharToOem(PChar(MSMessage[2]), PChar(MSMessage[2]));
ResultMsMessage := MSMessage[0] + #0 + MSMessage[1] + #0 + MSMessage[2];
WriteFile(MSHandle, Pointer(PChar(ResultMsMessage))^, Length(ResultMsMessage), MSWrite, nil);
Win32Check(MSWrite = Length(ResultMsMessage));
CloseHandle(MSHandle);
end;
← →
sucer (2004-02-29 06:43) [4]на этом возникает ошибка...
CharToOem(PChar(MSMessage[0]), PChar(MSMessage[0]));
CharToOem(PChar(MSMessage[1]), PChar(MSMessage[1]));
CharToOem(PChar(MSMessage[2]), PChar(MSMessage[2]));
← →
VMcL © (2004-02-29 13:13) [5]>>sucer (29.02.04 06:43) [4]
>на этом возникает ошибка...
Это очень плохо.
P.S. А не будешь ли ты так любезен написать, какая именно ошибка, чтобы те, кто пытается тебе помочь не занимались развитием своих телепатических способностей?
Страницы: 1 вся ветка
Текущий архив: 2004.04.25;
Скачать: CL | DM;
Память: 0.47 MB
Время: 0.023 c