我用VC2008 Qt开发的程序需要使用报表,就用Delphi 2009 做了个dll,将FastReport封装进去。
在调用测试时,最初使用LoadLibrary动态加载dll,没有任何问题。因为dll中函数较多,就改成静态链接。
结果每次退出程序时,出现:
Exeception EAccessViolation in module dbxmys.dll...我在 Delphi DLL中做了以下工作,仍然报错:
将ShareMem加到每个工作单元,包括project;
将borlndmm.dll复制到当前目录
去掉所有sharemem我在动态LoadLibrary时根本不使用ShareMem,也没有任何问题。我的DLL中只使用了LPCTSTR,根本不用string传参数。
由于代码太多,我贴出接口:
DLL:function OpenReportDB(pServerName,pDatabase,pUserName,pPassword:LPCTSTR): Bool; StdCall;
function CloseReportDB:Bool; StdCall;
function ReportPreview(parent:THandle; filePtr:LPCTSTR; sqlPtr:LPCTSTR):Bool; StdCall;
function ReportPrint(parent:THandle; filePtr:LPCTSTR;sqlPtr:LPCTSTR): Bool; StdCall;
function VehicleReport(isPrint:BOOL):BOOL; StdCall;dpr中exports定义:
exports
ReportPreview,
ReportPrint,
OpenReportDB,
CloseReportDB,
VehicleReport;C++中声明:
//静态调用 dll 的方法
extern "C" __declspec(dllimport) BOOL __stdcall OpenReportDB(LPWSTR,LPWSTR,LPWSTR,LPWSTR);//server,db,user,pwd
extern "C" __declspec(dllimport) BOOL __stdcall CloseReportDB(void);
extern "C" __declspec(dllimport) BOOL __stdcall ReportPreview(HWND,LPWSTR,LPWSTR); //filename,sql
extern "C" __declspec(dllimport) BOOL __stdcall ReportPrint(HWND,LPWSTR,LPWSTR); //filename,sql
extern "C" __declspec(dllimport) BOOL __stdcall VehicleReport(BOOL); //isPrint
#pragma comment(lib,"report.lib")请问有何策略找出问题所在?
在调用测试时,最初使用LoadLibrary动态加载dll,没有任何问题。因为dll中函数较多,就改成静态链接。
结果每次退出程序时,出现:
Exeception EAccessViolation in module dbxmys.dll...我在 Delphi DLL中做了以下工作,仍然报错:
将ShareMem加到每个工作单元,包括project;
将borlndmm.dll复制到当前目录
去掉所有sharemem我在动态LoadLibrary时根本不使用ShareMem,也没有任何问题。我的DLL中只使用了LPCTSTR,根本不用string传参数。
由于代码太多,我贴出接口:
DLL:function OpenReportDB(pServerName,pDatabase,pUserName,pPassword:LPCTSTR): Bool; StdCall;
function CloseReportDB:Bool; StdCall;
function ReportPreview(parent:THandle; filePtr:LPCTSTR; sqlPtr:LPCTSTR):Bool; StdCall;
function ReportPrint(parent:THandle; filePtr:LPCTSTR;sqlPtr:LPCTSTR): Bool; StdCall;
function VehicleReport(isPrint:BOOL):BOOL; StdCall;dpr中exports定义:
exports
ReportPreview,
ReportPrint,
OpenReportDB,
CloseReportDB,
VehicleReport;C++中声明:
//静态调用 dll 的方法
extern "C" __declspec(dllimport) BOOL __stdcall OpenReportDB(LPWSTR,LPWSTR,LPWSTR,LPWSTR);//server,db,user,pwd
extern "C" __declspec(dllimport) BOOL __stdcall CloseReportDB(void);
extern "C" __declspec(dllimport) BOOL __stdcall ReportPreview(HWND,LPWSTR,LPWSTR); //filename,sql
extern "C" __declspec(dllimport) BOOL __stdcall ReportPrint(HWND,LPWSTR,LPWSTR); //filename,sql
extern "C" __declspec(dllimport) BOOL __stdcall VehicleReport(BOOL); //isPrint
#pragma comment(lib,"report.lib")请问有何策略找出问题所在?
解决方案 »
- 把image里的图片(jpeg) 里的图片保存到access2000 ole字段 保存不上呀!!
- 我想用delphi 来实现下载 www.xx.com\aa.exe 到我的电脑 c:\ ,下载时并有进度条控件来显示下载的多少?,请问怎么实现?
- 不懂就问才会有进步,请高手指教,谢谢!
- FireBird数据库问题
- 如何在delphi中调用outlook
- 求助!将java代码翻译成delphi代码!简单的几句
- 请问谁有在DLL使用WINSOCK API接收消息的例子?
- 各们大侠们!做一个倒记时小程序怎么做呀?或有什么思路告诉我一下,小弟在这里谢谢了!!!
- 紧急求助:我该怎么区分当前操作系统是2000 server还是2000professional?
- ActiveX(ActiveForm)的自动更新问题?
- 编码问题,,
- 程序实现效率的问题,请教大家
lib /machine:x86 /def:report.def 生成vc使用的report.lib
LIBRARY report.dll
EXPORTSCloseReportDB@0 @2
OpenReportDB@16 @3
ReportPreview@12 @5
ReportPrint@12 @4
VehicleReport@4 @1