看到人家说netmessagebuffersend能调用信使服务,我照操了一次程序?怎么运行不了?请大家帮我看一下.(30分)

  • 主题发起人 主题发起人 koy0755
  • 开始时间 开始时间
K

koy0755

Unregistered / Unconfirmed
GUEST, unregistred user!
源代码如下.只是最简单地实现在向本机发信息.
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
function netmessagebuffersend(servername:pwidechar;
msgname:pwidechar;
formname:pwidechar;
buf:pwidechar;
var buflen:integer):integer;cdecl;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function netmessagebuffersend;external 'netapi32.dll' name 'netmessagebuffersend';
procedure TForm1.Button1Click(Sender: TObject);
var toname:array [0..64] of widechar;
wmsgtext:array [0..1000] of widechar;
msglen,i:integer;
toh,msg:string;
s,sd:integer;
begin
toh:='127.0.0.1';
msg:='sdfadfasdf';
for i:=0 to 64 do toname:=#0;
stringtowidechar(toh,toname,sd);
for i:=0 to 1000 do wmsgtext:=#0;
stringtowidechar(msg,wmsgtext,sd);
s:=netmessagebuffersend(nil,toname,nil,@wmsgtext,msglen);
end;

end.

居然说无法定位程序输入点netmessagebuffersend于动态链接库netapi32.dll上.请问这是怎么回事?
 
忘了说了,我的操作系统是win2003.不知跟操作系统有没关系?
 
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function NetMessageBufferSend(servername:pchar;
msgname:pchar;
fromname:pchar;
buf:pchar;
buflen:dword
):integer;stdcall;
external 'netapi32.dll';

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var toname:array [0..64] of widechar;
wmsgtext:array [0..1000] of widechar;
msglen,i:integer;
toh,msg:string;
s,sd:integer;
begin
toh:='127.0.0.1';
msg:='sdfadfasdf';
for i:=0 to 64 do toname:=#0;
stringtowidechar(toh,toname,sd);
for i:=0 to 1000 do wmsgtext:=#0;
stringtowidechar(msg,wmsgtext,sd);
s:=NetMessageBufferSend(nil,@toname,nil,@wmsgtext,msglen);
end;

end.
 

function netmessagebuffersend(servername:pwidechar;
msgname:pwidechar;
formname:pwidechar;
buf:pwidechar;
var buflen:integer):integer;cdecl;
改为
function NetMessageBufferSend(servername:pchar;
msgname:pchar;
fromname:pchar;
buf:pchar;
buflen:dword
):integer;stdcall;
external 'netapi32.dll';
就能运行了.
不还还是有点不明白的地方.
cdecl;和stdcall;是什么意思?
 
其实要调用dll里的函数.到底有什么规律?
 
接受答案了.
 
后退
顶部