type
ECompileError = class(Exception)
pos: Integer;
len: Integer;
constructor Create(const Msg: string; position, length: Integer);
end;
用法
on E: ECompileError do
begin
Richedit1.SelStart := E.pos;
Richedit1.SelLength := E.len;
Richedit1.SetFocus;
label2.Caption := '错误:'+ E.Message;
end;
ECompileError = class(Exception)
pos: Integer;
len: Integer;
constructor Create(const Msg: string; position, length: Integer);
end;
用法
on E: ECompileError do
begin
Richedit1.SelStart := E.pos;
Richedit1.SelLength := E.len;
Richedit1.SetFocus;
label2.Caption := '错误:'+ E.Message;
end;
因为pascal是编译型的,所以不可能在可执行文件中得到源代码,
如果你自己作的编译,用我的方法可以取出
如果是delphi作编译,建议不要让用户看到源代码。
我把DELPHI中的程序给你看,你看怎么取错误代码?
procedure TForm1.Button3Click(Sender: TObject);
var
ResponseID:widestring; //响应码
Identifier:Widestring; //CTL标识
begin
ResponseID:=memo2.Lines.text;
Identifier:=edit2.text;
Itest.Identifier:=Identifier;
try
Itest.Auth(ResponseID,SKYNETPKICOM_VERIFY_SIGNATURE_AND_CERTIFICATE_AND_CTL_AS_CERT);//验证动态口令登录,证书和信任列表
showmessage('动态口令验证成功!');
except
showmessage('动态口令验证不成功!');
end;
end;
怎么取错误代码呢?
谢谢!
Err:Dword; //<---------------------------
.....
try
Itest.Auth(ResponseID,SKYNETPKICOM_VERIFY_SIGNATURE_AND_CERTIFICATE_AND_CTL_AS_CERT);//验证动态口令登录,证书和信任列表
showmessage('动态口令验证成功!');
except
Err:=GetLastError;//<--------------------
showmessage('动态口令验证不成功!'+'错误代码:'+IntTostr(Err));
end;
你那样取到的错误代码是系统错误代码,而不是我想取的错误代码。
能和我给出的VB程序吻合吗?
并且取得的错误代码全为零,是肯定不对的。
各位帮助,下午领导要看!急切盼望有人能解决!!!
谢谢!!!谢谢!!!!
看MSDN帮助试试,Error Codes
type
ECompileError = class(Exception)
pos: Integer;
len: Integer;
constructor Create(const Msg: string; position, length: Integer);
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; ECompileError = class(Exception)
private
pos: Integer;
len: Integer;
constructor Create(const Msg: string; position, length: Integer);
public
end;var
Form1: TForm1;
{$R *.dfm}
Constructor EcompileError.Create(Const Msg:String;Position,Length:Integer);..............
try
Itest.Auth(ResponseID,SKYNETPKICOM_VERIFY_SIGNATURE_AND_CERTIFICATE_AND_CTL_AS_CERT);//验证动态口令登录,证书和信任列表
showmessage('动态口令验证成功!');
except
On E:EcompileError do
showmessage('动态口令验证不成功!'+'错误代码:'+E.Message);
end;
begin
/////////
end;
Except
On E:Exception Do
Begin
ShowMessage(E.Message);
ShowMessage(E.ClassName);
End;
End;错误的ID好象没有
只能取到错误原因,取不到错误代码。
还能有什么办法吗?
谢谢你!!!!
拜托了。
ADODataSet1.Post;
except
on EOLEException do
showmessage(ADOConnection1.Errors.Item[0].NativeError)
end;
try
ADODataSet1.Post;
except
on EOLEException do
showmessage(IntToStr(ADOConnection1.Errors.Item[0].NativeError))
end;
你说的我好像根本不懂,这样取出的错误代码是什么的错误代码?
能不能说的详细点呢?一定要和我给的VB程序联系一下哟。
感谢你!!!
try
ADODataSet1.Post;
except
on EOLEException do
先用str := IntToStr(ADOConnection1.Errors.Item[0].NativeError) + '*'
ADOConnection1.Errors.Item[0].Description
检测出错误代码及错误信息再对错误分别作处理(其中Description为错误信息内容);
end;