试做了一个DLL,可运行时总是出错,代码如下:
library Project2;uses
SysUtils,
Classes,
Graphics;{$R *.res}function PICtoBMP(PIC: TPicture): TBitmap;
begin
Result := TBitmap.Create;
Result.Assign(PIC.Graphic);
end;exports
PICtoBMP;begin
end.这个函数直接在单元里调用是没有问题的,可是通过dll来调用总是提示Cannot assign a XXX to TBitmap,就算我传递的是一副BMP图像都是如此提示,感觉上assign方法不能使用不知道做dll应该注意些什么?
library Project2;uses
SysUtils,
Classes,
Graphics;{$R *.res}function PICtoBMP(PIC: TPicture): TBitmap;
begin
Result := TBitmap.Create;
Result.Assign(PIC.Graphic);
end;exports
PICtoBMP;begin
end.这个函数直接在单元里调用是没有问题的,可是通过dll来调用总是提示Cannot assign a XXX to TBitmap,就算我传递的是一副BMP图像都是如此提示,感觉上assign方法不能使用不知道做dll应该注意些什么?
解决方案 »
- delphi 调用 tuxedo服务
- MSComm控件安装后,在ActiveX面板中找不到相应的组件
- 在注册DPK包编译时提示找不到.pas文件,如何解决?
- 在ASP.NET中使用DELPHI语言脚本
- 怎么样用Delphi生成xml文件
- 怎樣設置mastedit讓輸入為大寫
- 如何将image中的图像bitblt到其他的DC中,比如屏幕上?
- 急!!!请问paradox数据库有没有最大限制!!我存到2G它就不干活了!!!请问有没有好的解决方法!!!是不是有这个限制??还是我那点没做好!!谢谢!
- 请问在程序中动态的创建一个文本文件怎么做,又如何向这个文本文件写入信息,读出信息??谢谢!!
- 怎么在自己的机器上做FTP的软件呢
- 不知是怎么个错,但却错了,急》》》》》
- 请大侠帮忙看看这个sql语句错在什么地方?
begin
Result := TBitmap.Create;
Result.Assign(PIC.Graphic);
end;
// 直接移到调用工程 测试一下
begin
Result := TBitmap.Create; // 可能就是这个result的缘故了... 一般不要在DLL分配空间 传出
Result.Assign(PIC.Graphic);
end;一般是在调用方分配空间 然后DLL在里面改写,填充之类的...function PICtoBMP(PIC: TPicture;var BitMap:TBitmap):Boolean
begin
Result := False;
if BitMap = nil then
Exit;
BitMap.Assign(PIC.Graphic); Result := True;
end;try this..
SysUtils,
Classes,
Graphics;{$R *.res}function PICtoBMP(PIC: TPicture): TBitmap; stdcall; //
begin
Result := TBitmap.Create;
Result.Assign(PIC.Graphic);
end;exports
PICtoBMP;begin
SysUtils,
Classes,
Graphics;{$R *.res}function PICtoBMP(PIC: TPicture): TBitmap; stdcall; //
begin
Result.Assign(PIC.Graphic);
end;exports
PICtoBMP;begin