function netmessagebuffersend(servername:pwidechar;
toname:pwidechar;
fromname:pwidechar;
buf: pwidechar;
var buflen:integer):integer;stdcall; external 'netapi32.dll' name 'netmessagebuffersend';
const
max_length=1025;
var
string1,string2,string3:string;
pstring1,pstring2:array[0..28] of pwidechar;
pstring3:array[0..1024]o of pwidechar;
length,i,j:integer;
//下面先进行一个转换,讲string类型转换成api函数的pwidechar类型
begin
for i:=0 to 28 do pstring1[i]:=#0;//将所有的字节都填充#0字符
stringtowidechar(string1,psting1,length);//这个rtl函数可以完成这个转换
for i:=0 to 28 do pstring2[i]:=#0
stringtowidechar(string2,psting2,length);
for i:=0 to 1024 do pstring1[i]:=#0
stringtowidechar(string3,psting3,length);
//length返回实际转换的空间(字节长度),不要管他!
//转换完成了,现在可以调用这个api了
j:=netmessagebuffersend(nil,@psting2,@pstring1,@pstring3,max_length);
Private Declare Function NetMessageBufferSend Lib "netapi32" (ByVal ServerName As Byte(), ByVal ToName As Byte(), ByVal FromName As Byte(), ByVal MsgBuffer As Byte(), ByRef MsgLen As Integer) As Integer