缘
缘尽
Unregistered / Unconfirmed
GUEST, unregistred user!
我的dll代码
library regdll;
{ 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. }
uses
SysUtils,
Classes, inifiles;
{$R *.res}
function cjwj(xrsj:string):string;stdcall;
var found:integer;
sr: TSearchRec;
myinifile:TInifile;
filename:string;
xjm,gjz,drz:string;
begin
xjm:='ssss';
gjz:='ssss';
Found := FindFirst(ExtractFilePath(Paramstr (0))+'jiu.ini', faAnyFile , sr);
if found=0 then
begin
if myinifile.ReadString(xjm,gjz,drz)='' then
begin
filename:=ExtractFilePath(paramstr(0))+'jiu.ini';
myinifile:=TInifile.Create(filename);
myinifile.writestring(xjm,gjz,xrsj);
result:=xrsj;
end
else
begin
result:=myinifile.ReadString(xjm,gjz,drz);
end;
end
else
begin
result:='';
end;
end;
function wrqjm(var rq: string):string;
var
yrq:array[1..10]of string;
zjs:array[1..11]of string;
i:integer;
fhjm:string;
s:string;
begin
for i:=1 to 10 do
begin
yrq:=copy(rq,i,1);
end;
yrq[9]:=inttostr(strtoint(yrq[9])+6);
yrq[8]:='0';
yrq[6]:=inttostr(strtoint(yrq[6])+7);
yrq[5]:='1';
yrq[3]:=inttostr(strtoint(yrq[3])+2);
yrq[2]:=inttostr(strtoint(yrq[2])+5);
yrq[1]:=inttostr(strtoint(yrq[1])+5);
//第1个随机数
for i:=1 to 11 do
begin
zjs:='';
end;
for i:=1 to 6 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[1]:=zjs[1]+s;
end;
//第2个随机数
for i:=1 to 6 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[2]:=zjs[2]+s;
end;
//第3个随机数
for i:=1 to 5 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[3]:=zjs[3]+s;
end;
//第4个随机数
for i:=1 to 4 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[4]:=zjs[4]+s;
end;
//第5个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[5]:=zjs[5]+s;
end;
//第6个随机数
for i:=1 to 2 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[6]:=zjs[6]+s;
end;
//第7个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[7]:=zjs[7]+s;
end;
//第8个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[8]:=zjs[8]+s;
end;
randomize;
s:=inttostr(random(9));
zjs[8]:=zjs[8]+s;
//第9个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[9]:=zjs[9]+s;
end;
//第10个随机数
for i:=1 to 2 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[10]:=zjs[10]+s;
end;
//第11个随机数
for i:=1 to 7 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[11]:=zjs[11]+s;
end;
randomize;
s:=inttostr(random(9));
zjs[11]:=zjs[11]+s;
fhjm:=zjs[1]+yrq[9]+zjs[2]+yrq[6]+zjs[3]+yrq[2]+zjs[4]+yrq[4]+zjs[5]+yrq[1]+zjs[6]+yrq[5]+zjs[7]+yrq[3]+zjs[8]+yrq[7]+zjs[9]+yrq[10]+zjs[10]+yrq[8]+zjs[11];
result:=fhjm;
end;
function wrqfjm(var jmrq: string): string;
var
yrq:array[1..10]of string;
i:integer;
fhjm:string;
begin
yrq[1]:=copy(jmrq,53,1);
yrq[2]:=copy(jmrq,37,1);
yrq[3]:=copy(jmrq,65,1);
yrq[4]:=copy(jmrq,46,1);
yrq[5]:=copy(jmrq,58,1);
yrq[6]:=copy(jmrq,26,1);
yrq[7]:=copy(jmrq,73,1);
yrq[8]:=copy(jmrq,85,1);
yrq[9]:=copy(jmrq,13,1);
yrq[10]:=copy(jmrq,80,1);
yrq[9]:=inttostr(strtoint(yrq[9])-6);
yrq[8]:='-';
yrq[6]:=inttostr(strtoint(yrq[6])-7);
yrq[5]:='-';
yrq[3]:=inttostr(strtoint(yrq[3])-2);
yrq[2]:=inttostr(strtoint(yrq[2])-5);
yrq[1]:=inttostr(strtoint(yrq[1])-5);
for i:=1 to 10 do
begin
fhjm:=fhjm+yrq;
end;
result:=fhjm;
end;
exports
cjwj;
exports
wrqjm;
exports
wrqfjm;
begin
end.
我在程序中使用
function wrqjm(var rq:string):string;stdcall;
external 'regdll.dll';
procedure Tmain.Button1Click(Sender: TObject);
var
rq:string;
rqjm:string;
begin
rq:=datetostr(date);
self.Edit1.Text:=wrqjm(rq);
end;
运行是报的错误
"is not a valid integer value"
library regdll;
{ 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. }
uses
SysUtils,
Classes, inifiles;
{$R *.res}
function cjwj(xrsj:string):string;stdcall;
var found:integer;
sr: TSearchRec;
myinifile:TInifile;
filename:string;
xjm,gjz,drz:string;
begin
xjm:='ssss';
gjz:='ssss';
Found := FindFirst(ExtractFilePath(Paramstr (0))+'jiu.ini', faAnyFile , sr);
if found=0 then
begin
if myinifile.ReadString(xjm,gjz,drz)='' then
begin
filename:=ExtractFilePath(paramstr(0))+'jiu.ini';
myinifile:=TInifile.Create(filename);
myinifile.writestring(xjm,gjz,xrsj);
result:=xrsj;
end
else
begin
result:=myinifile.ReadString(xjm,gjz,drz);
end;
end
else
begin
result:='';
end;
end;
function wrqjm(var rq: string):string;
var
yrq:array[1..10]of string;
zjs:array[1..11]of string;
i:integer;
fhjm:string;
s:string;
begin
for i:=1 to 10 do
begin
yrq:=copy(rq,i,1);
end;
yrq[9]:=inttostr(strtoint(yrq[9])+6);
yrq[8]:='0';
yrq[6]:=inttostr(strtoint(yrq[6])+7);
yrq[5]:='1';
yrq[3]:=inttostr(strtoint(yrq[3])+2);
yrq[2]:=inttostr(strtoint(yrq[2])+5);
yrq[1]:=inttostr(strtoint(yrq[1])+5);
//第1个随机数
for i:=1 to 11 do
begin
zjs:='';
end;
for i:=1 to 6 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[1]:=zjs[1]+s;
end;
//第2个随机数
for i:=1 to 6 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[2]:=zjs[2]+s;
end;
//第3个随机数
for i:=1 to 5 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[3]:=zjs[3]+s;
end;
//第4个随机数
for i:=1 to 4 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[4]:=zjs[4]+s;
end;
//第5个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[5]:=zjs[5]+s;
end;
//第6个随机数
for i:=1 to 2 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[6]:=zjs[6]+s;
end;
//第7个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[7]:=zjs[7]+s;
end;
//第8个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[8]:=zjs[8]+s;
end;
randomize;
s:=inttostr(random(9));
zjs[8]:=zjs[8]+s;
//第9个随机数
for i:=1 to 3 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[9]:=zjs[9]+s;
end;
//第10个随机数
for i:=1 to 2 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[10]:=zjs[10]+s;
end;
//第11个随机数
for i:=1 to 7 do
begin
randomize;
s:=inttostr(random(99));
if length(s)<2 then s:='0'+s;
zjs[11]:=zjs[11]+s;
end;
randomize;
s:=inttostr(random(9));
zjs[11]:=zjs[11]+s;
fhjm:=zjs[1]+yrq[9]+zjs[2]+yrq[6]+zjs[3]+yrq[2]+zjs[4]+yrq[4]+zjs[5]+yrq[1]+zjs[6]+yrq[5]+zjs[7]+yrq[3]+zjs[8]+yrq[7]+zjs[9]+yrq[10]+zjs[10]+yrq[8]+zjs[11];
result:=fhjm;
end;
function wrqfjm(var jmrq: string): string;
var
yrq:array[1..10]of string;
i:integer;
fhjm:string;
begin
yrq[1]:=copy(jmrq,53,1);
yrq[2]:=copy(jmrq,37,1);
yrq[3]:=copy(jmrq,65,1);
yrq[4]:=copy(jmrq,46,1);
yrq[5]:=copy(jmrq,58,1);
yrq[6]:=copy(jmrq,26,1);
yrq[7]:=copy(jmrq,73,1);
yrq[8]:=copy(jmrq,85,1);
yrq[9]:=copy(jmrq,13,1);
yrq[10]:=copy(jmrq,80,1);
yrq[9]:=inttostr(strtoint(yrq[9])-6);
yrq[8]:='-';
yrq[6]:=inttostr(strtoint(yrq[6])-7);
yrq[5]:='-';
yrq[3]:=inttostr(strtoint(yrq[3])-2);
yrq[2]:=inttostr(strtoint(yrq[2])-5);
yrq[1]:=inttostr(strtoint(yrq[1])-5);
for i:=1 to 10 do
begin
fhjm:=fhjm+yrq;
end;
result:=fhjm;
end;
exports
cjwj;
exports
wrqjm;
exports
wrqfjm;
begin
end.
我在程序中使用
function wrqjm(var rq:string):string;stdcall;
external 'regdll.dll';
procedure Tmain.Button1Click(Sender: TObject);
var
rq:string;
rqjm:string;
begin
rq:=datetostr(date);
self.Edit1.Text:=wrqjm(rq);
end;
运行是报的错误
"is not a valid integer value"