NetMessageBuffering example

zhaozj2021-02-17  89

Unit unit1;

Interface

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; function ToUnicode (str: string; dest: PWideChar): integer; function SendMsg (Toh, From, Msg: string): integer; function NetMessageBufferSend (servername: PWideChar; MsgName: PWideChar; FromName: PWideChar; Buf: PWideChar; var bufLen: integer): integer; cdecl; type TForm1 = class (TForm) Button1: TButton; ComboBox1: TComboBox; Memo1: TMemo; procedure Button1Click ( Sender: TOBJECT); private {private declarations}

Var Form1: TFORM1;

implementation {$ R * .dfm} function NetMessageBufferSend; external 'netapi32.dll' name 'NetMessageBufferSend'; function ToUnicode (str: string; dest: PWideChar): integer; var len: integer; begin StringToWideChar (str, dest, len) Result: = LEN; End; Function Sendmsg (TOH, FROM, MSG: String): Integer; var Toname: Array [0..64] of widechar; wmsgtext: array [0..1000] of widechar; msglen, i : Integer; Begin for i: = 0 to 64 do toname [i]: = # 0; Tounicode (TOH, TONAME); for i: = 0 to 1000 do wmsgtext [i]: = # 0; Tounicode (MSG, WMSGText ); Result: = NetMessageBufferSend (nil, ToName, nil, @ WMsgText, MsgLen); end; procedure TForm1.Button1Click (Sender: TObject); varsize: integer; begin sendmsg ( '192.168.2.16', ', 192.168.2.16' , 'KJJKKJKJKJ'); END;

End.

转载请注明原文地址:https://www.9cbs.com/read-31140.html

New Post(0)