"Access violation" 在 DLL 中调用外部函数时出错(在 unzipper.dll 中解压)

"Access violation" error when calling external function in DLL (unzip in unzipper.dll)

我正在尝试使用在线获得的 .dll 文件解压缩文件,但是每当我从代码部分调用 extract me 过程时,我都会收到以下错误:

Exception:
Access violation at address 025DA648. Read of address 00000000.

程序:

procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll cdecl delayload';

procedure ExtractMe(src, target : AnsiString);
begin
  unzip(ExpandConstant(src), ExpandConstant(target));
end;

Code 部分内调用:

procedure UnzipFiles();
var
  NSSMPath: string;
  target: AnsiString;
begin
  NSSMPath := ExpandConstant('{src}\..\nssm-2.24.zip');
  target := 'C:\files';
  begin
    //Unzips files Checks for presence of files before to save time.
    //NSSM
    if not (FileExists('C:\files\nssm-2.24'))then
    begin
      ExtractMe(NSSMPath, target)
    end;
  end;
end;

unzip 必须声明为 stdcall,而不是 cdecl。只需使用 UnzipExample.iss:

中的声明
procedure unzip(src, target: AnsiString);
external 'unzip@files:unzipper.dll stdcall delayload';