调用DLL函数返回字符串出错
下面是我写的Dll里面的函数:
===============================
Function GetSoftInfo(Kind: String):String;stdCall
var
strKind: String;
Begin
strKind := Kind;
If strKind='Version' Then
Result := '系统1。0'
Else IF strKind='Corporation' Then
Result := '有限公司'
Else If strKind='Author' Then
Result :='设计制作';
End;
下面是库的调用
========================================
procedure TfrmMain.FormShow(Sender: TObject);
Type TGetSoftInfo = function(Kind:String):String;StdCall;
var
LibHandle: THandle;
SoftInfo: TGetSoftInfo;
begin
LibHandle := LoadLibrary('SoftInfo.dll');
If LibHandle = 0 Then
Begin
Application.MessageBox('部分程序已毁坏,请重新安装','网站更新程序',MB_OK+MB_ICONERROR);
Application.Terminate;
End
Else
Begin
@SoftInfo := GetProcAddress(LibHandle,'GetSoftInfo');
If @SoftInfo=nil then
Application.MessageBox('程序信息库出现错误,请立即联系供应商','网站更新程序',MB_OK+MB_ICONERROR)
Else
Begin
frmMain.Caption := SoftInfo('Version');//出错行
lblVersion.Caption := SoftInfo('Version');//出错行
lblCorp.Caption := softInfo('Corporation');//出错行
End;
FreeLibrary(LibHandle);
End;
end;
错误提示:
=========
Access violation at address 004042D6 in module 'WebUpdate.exe'. Read of address 01030C0C.
急需帮助,万分感激!