关于供Authorware使用的dll中的参数的转入和一般整型的转出大家可参看:
<a href="http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=233074">
http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=233074</a>
要想传出字符类型就要麻烦一些了。
下面我就举一个实例,自己再改吧。
unit myunit;
interface
uses Dialogs,SysUtils,windows,forms;
function MsgBox(msg:string;mbType:Word;title:string):WORD;export;{$ifdef WIN32} stdcall
{$endif}
function rstr
char;export;{$ifdef WIN32} stdcall
{$endif}
implementation
function MsgBox(msg:string;mbType:Word;title:string):WORD;
VAR
LpText,lpCaption
char;
h:HWND;
begin
strpcopy(lpText,title);
strpcopy(lpCaption,msg);
h:=GetActiveWindow();
MsgBox:=MessageBox(h,lpText,lpCaption,mbType);
end;
//这里将字符串的处理放在全局堆中是一个关键
function rstr
char;
var
hstr:HGLOBAL;
lpstr: pointer
str:string;
begin
str:='This is a test string!';
hstr:=(GlobalAlloc(GMEM_MOVEABLE, length(str)+1));
if hstr<>0 then
begin
lpstr:=GlobalLock(HGLOBAL(hstr));
lstrcpy(pchar(lpstr),pchar(str));
GlobalUnlock(HGLOBAL(hstr));
end;
result:=pchar(hstr);
end;
资源文件如下:
// test.rc
1 DLL_HEADER PRELOAD DISCARDABLE
begin
"MsgBox/0",
"rstr/0",
"/0"
END
msgbox DLL_HEADER PRELOAD DISCARDABLE
begin
"/0",
"W/0",
"SWS/0",
"Result := MsgBox(msg,mbType,title)/r/n",
"/r/n",
"show messagebox/0",
END
rstr DLL_HEADER LOADONCALL DISCARDABLE
begin
"/0",
"S/0",
"V/0",
"rstr(v)/r/n",
"/r/n",
"/0",
END
用brc32 -r -fotest.res test.rc编译生成test.res。
主工程文件如下:
library authorware;
uses
SysUtils,
Classes,
myunit in 'myunit.pas';
{$R a32w.res}
exports MsgBox,
rstr;
begin
end.