哪位见过名为 gbhcards.dll 的文件,并且知道怎么使用,进来交流交流呀! (内附源代码) (0分)

  • 主题发起人 主题发起人 阿魁
  • 开始时间 开始时间

阿魁

Unregistered / Unconfirmed
GUEST, unregistred user!
这是我在 zizi (大富翁成员)的“纸牌算命”里见到的文件,是用来显示纸牌图像的,<br>我也想做个纸牌程序,所以想研究该文件怎么使用。<br><br>我看了zizi的源程序,发现在该文件里有一个导出函数:drawcard,原型如下:<br>function drawcard(bmp : TBitmap; i : integer) : integer;<br><br>bmp就是显示纸牌图像的地方,i估计是要显示的纸牌的序号。<br>于是我自己做了个测试程序,如下:<br>==========================================================================<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls, ExtCtrls, jpeg;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Image1: TImage;<br>&nbsp; &nbsp; Edit1: TEdit;<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure FormDestroy(Sender: TObject);<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br>&nbsp; //这是我定义的函数变量<br>&nbsp; fnDrawCard : function(bmp : TBitmap; i : integer):integer;<br>&nbsp; h : THandle;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp; //加载DLL文件<br>&nbsp; h := LoadLibraryEx(pchar(ExtractFilePath(application.ExeName)+'card.dll'),0,0);<br>&nbsp; if h=0 then<br>&nbsp; begin<br>&nbsp; &nbsp; showMessage('load library failed!');<br>&nbsp; &nbsp; application.Terminate;<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br><br>&nbsp; //取得函数地址<br>&nbsp; @fnDrawCard := GetProcAddress(h,'drawcard');<br><br>&nbsp; if @fnDrawCard=nil then<br>&nbsp; begin<br>&nbsp; &nbsp; showMessage('get procedure address failed!');<br>&nbsp; &nbsp; FreeLibrary(h);<br>&nbsp; &nbsp; application.Terminate;<br>&nbsp; &nbsp; exit;<br>&nbsp; end;<br><br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>&nbsp; FreeLibrary(h);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; //在image1里画纸牌<br>&nbsp; fnDrawCard(image1.Picture.Bitmap,strToInt(edit1.Text));<br>end;<br><br>end.<br>===================================================<br>注:我已把该dll文件改名为card.dll<br><br>问题是,编译没问题,执行时报错,说是内存访问问题,大家谈谈看法吧。<br>
 
用F8看看到哪一步出错的。。
 
我已在主页http://guanbh.top263.net上放了gbhcards.dll的源码。<br>用d5编译的dll不能在d6编译的程序下使用,反之亦然。<br>我是个不求甚解的人。为什么会这样,我还没搞清楚。<br>
 
接受答案了.
 
后退
顶部