innosetup 5.2.3导入DLL后出错的问题?(200分)

  • 主题发起人 主题发起人 gf101xt
  • 开始时间 开始时间
G

gf101xt

Unregistered / Unconfirmed
GUEST, unregistred user!
5.2.3导入DLL后出错的问题?
我使用delphi做个一个DLL
使用代码如下:
library xxxx;
uses
Windows;
const
Base64: string = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz~#%&*+-';
UnBase64: array[0..255] of byte =
(128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //0-15
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //16-31
128,128,128, 58,128, 59, 60,128, 128,128, 61, 62,128, 63,128,128, //32-47
128,128, 0, 1, 2, 3, 4, 5, 6, 7,128,128,128,128,128,128, //48-63
128, 8, 9, 10, 11, 12, 13, 14, 15,128, 16, 17, 18, 19, 20,128, //64-79
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,128,128,128,128,128, //80-95
128, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,128, 43, 44, 45, //96-111
46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,128,128,128, 57,128, //112-127
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //128-143
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //144-159
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //160-175
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //176-191
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //192-207
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //208-223
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128, //224-239
128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128);
//240-255
function Base64Encode(const s: string): string;
var
s4: string;
i, j, k: integer;
b: byte;
begin
Result := '';
SetLength(s4, 4);
b := 0;
i := 1;
j := 2;
k := 2;
while i <= length(s)do
begin
b := b or ((ord(s) and $C0) shr k);
inc(k,2);
s4[j] := Base64[(ord(s) and $3F)+1];
inc(i);
inc(j);
if j > 4 then
begin
s4[1] := Base64[b+1];
b := 0;
j := 2;
k := 2;
Result := Result + s4;
end;
end;
if j <> 2 then
begin
// Flush data in s4.
s4[j] := '.';
s4[1] := Base64[b+1];
Result := Result + s4;
SetLength(Result, Length(Result) - (4 - j));
end
else
Result := Result + '.';
end;

function Base64Decode(const s: string): string;
var
i, j, k: integer;
b: byte;
begin
Result := '';
b := 0;
i := 1;
j := 0;
k := 2;
while (i <= length(s)) and (s <> '.')do
begin
if j = 0 then
begin
b := UnBase64[ord(s)];
k := 2;
end
else
begin
Result := Result + chr(UnBase64[ord(s)] or ((b shl k) and $C0));
inc(k,2);
end;
inc(j);
j := j and 3;
inc(i);
end;
end;

exports
Base64encode,
Base64decode;
begin
end.

编译生成xxxx.dll文件
然后使用下面脚本调用
但是在加粗的那行出错,请高手们解答一下
function Base64Encode(const s:string):string;
external 'Base64Encode@{app}/xxxx.dll stdcall uninstallonly';
function Base64Decode(const s:string):string;
external 'Base64Decode@{app}/xxxx.dll stdcall uninstallonly';
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
z:string;
begin
if CurUninstallStep = usUninstall then
begin
z:=Base64Decode(z);
UnloadDLL(ExpandConstant('{app}/xxxx.dll'));//此行出错
end;
end;
 
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
用 pchar 代替 string
 
对的 ,我后来也是这么解决了,谢谢!
 

Similar threads

I
回复
0
查看
630
import
I
I
回复
0
查看
630
import
I
I
回复
0
查看
670
import
I
后退
顶部