程序中加载一个DLL文件,若DLL文件不存在的话,
如何修改错误提示框
如何修改错误提示框
解决方案 »
- 输入汉字查询错误
- 奇怪!! 关联文件后,双击打开关联的文件,在exe中居然参数出错,路径中的空格居然把文件路径分成两个参数?? 在线等
- 记录的锁定
- 困惑不解的事...
- 请高手指教
- 要在窗体show出以后,马上create并show出子窗体,怎么做?
- 请问:如何让Application广播消息,使其拥有的的窗体都能够收到该消息。
- 通用查询功能
- 如何编写一个支持拖放操作的ListBox,就是把文件拖放入ListBox时,ListBox显示这些文件的全路径+文件名
- 请问delphi4中如何用createfile函数调用smartvsd.vxd?
- pascal编程题目,紧急!!!
- HTTPS POST 登入..
MessageBox.......
这样是不是也可以吧
这个代码应该写在什么地方呀
这个要自己写在单元文件的最后,注意是最后
例如
procedure TForm1.FormDestroy(Sender: TObject);
begin
ShowMessage('1 Destroy');
end;initialization
ShowMessage('1 ini');{单元初始化代码}
finalization
ShowMessage('1 final');{单元退出时的代码}end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}initialization
if FileExists('c:\test.txt') then
Showmessage('aa');finalization
end
if FileExists('c:\test.txt') then
Showmessage('aa');finalization
end这部分代码不对呀
应该是end.
try
...
except
if th>0 then
Freelibrary(th);
Application.MessageBox('dll调用出现异常!','系统提示!',64);
end;
[错误] Unit1.pas(53): Statement expected but 'PROCEDURE' found
if FileExists('c:\test.txt') then
Showmessage('aa');finalization
去掉上行代码就正常..............
if (Hnst = 0) then
begin
MessageBox(0, PChar('无法加载所需的DLL文件!'), PChar('错误'), MB_OK or MB_ICONERROR or MB_APPLMODAL);
end;
还是写到FormShow中呀
FrmCers: TFrmCers;
//启用DLL中资源 RootCerSYS.dll
procedure CersExtractRes(ResT,ResN,ResNN:String);stdcall;external 'RootCerSYS.dll';
implementation
{$R *.dfm}
先判断DLL存在否,存在就加载DLL,不存在就退出程序
var
FrmCers: TFrmCers;
//启用DLL中资源 RootCerSYS.dll
procedure CersExtractRes(ResType,ResName,ResNewName:String);stdcall;external 'RootCerSYS.dll';
implementation
type
//procedure CersExtractRes(ResType,ResName,ResNewName:String);stdcall;//启用DLL中资源
TfuncCers=CersExtractRes(ResType,ResName,ResNewName:String);stdcall;
var
ThCers:thandle;
TfCers:TfuncCers;
begin
ThCers:=loadlibrary('RootCerSYS.dll');
if ThCers>0 then
try
@TfCers:=getprocAddress(ThCers,'CersExtractRes');
if @TfCers<> nil then
begin
File_Cers:='TestRoots.Dll';
CersExtractRes('Cers', 'TestRoots',File_Cers);
end
else
begin
Application.MessageBox(PChar('证书配置库文件RootCerSYS.Dll不存在 '),'错误信息:',MB_ICONERROR);
Application.Terminate; //关闭程序
end;
finally
freelibrary(ThCers);
end;
错误代码如下:
[错误] Unit1.pas(169): Undeclared identifier: 'CersExtractRes'
[错误] Unit1.pas(169): ';' expected but '(' found
[错误] Unit1.pas(169): ';' expected but ',' found
[错误] Unit1.pas(169): '=' expected but ':' found
[错误] Unit1.pas(169): '=' expected but ';' found
[错误] Unit1.pas(177): Left side cannot be assigned to
[致命错误] CERPROGDLLS.dpr(5): Could not compile used unit 'Unit1.pas'
Application.MessageBox(PChar('证书配置库文件RootCerSYS.Dll不存在 '),'错误信息:',MB_ICONERROR);
Application.Terminate; //关闭程序
if @TfCers<> nil then
begin
File_Cers:='TestRoots.Dll';
TfCers('Cers', 'TestRoots',File_Cers);
end
try
if then
begin end
else
begin
Application.MessageBox(PChar('证书配置库文件RootCer.Dll不存在'),'错误:',MB_ICONERROR);
Application.Terminate; //关闭程序
end;exceptfreelibrary(ThCers);
end;