Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2002.01.31;
Скачать: CL | DM;

Вниз

net send без имени компа?   Найти похожие ветки 

 
marconi ©   (2001-11-29 10:31) [8]


unit Net_Send2;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, lmmsg;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
ComboBox1: TComboBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

Function UserName: string;
var
Size: DWORD;
Buffer : PChar;
begin

Size:=32;
GetMem(Buffer, Size);
try
if GetUserName(Buffer,Size) then
Result := StrPas("TEST"); //StrPas(Buffer); <--- Имя !!! от кого мессага
finally
FreeMem(Buffer);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
Code : Integer;
MsgBuff : pWideChar;
Size, NewSize : Integer;
User, UName : Array[0..127] Of WideChar;
begin

Size := Length(Memo1.Text);
StringToWideChar(ComboBox1.Text, User, SizeOf(User) div 2);
StringToWideChar(UserName, UName, SizeOf(UName) div 2);

NewSize := Size * 2;
MsgBuff := VirtualAlloc(nil, Size, Mem_Commit, Page_ReadWrite);
MultiByteToWideChar(CP_ACP, 0, PChar(Memo1.Text), Size, MsgBuff, NewSize);

Code := NetMessageBufferSend("", User, UName, MsgBuff, lStrLenW(MsgBuff)* SizeOf(pWideChar));

If Code = 0 Then
Label3.Caption := "Message was sent Successfully!"
Else
Label3.Caption := "Returned Error Code: " + IntToStr(Code);


{case a of
ERROR_ACCESS_DENIED : ShowMessage("The user does not have access to the requested information.");
ERROR_INVALID_PARAMETER : ShowMessage("The specified parameter is invalid.");
ERROR_NOT_SUPPORTED : ShowMessage("This network request is not supported");
NERR_NameNotFound : ShowMessage("The user name could not be found.");
NERR_NetworkError : ShowMessage("A general failure occurred in the network hardware");
Else
ShowMessage("Unknow Error");
end;
}

end;

end.



Страницы: 1 вся ветка

Текущий архив: 2002.01.31;
Скачать: CL | DM;

Наверх




Память: 0.46 MB
Время: 0.014 c
14-100067
Digitman
2001-12-07 17:41
2002.01.31
Дж.Харриссон - кто он ?


4-100110
Song
2001-12-02 22:50
2002.01.31
Узнать, что программа уже запущена


3-99842
Петрович
2001-12-26 06:03
2002.01.31
Для чего нужна конструкция For Update


3-99901
Oleon
2001-12-28 17:32
2002.01.31
Ну прямо никто не знает что-ли? Не может быть.


6-100029
Alex_Sudakov
2001-11-01 11:56
2002.01.31
Дурацкий вопрос...:)