T
tianqiu
Unregistered / Unconfirmed
GUEST, unregistred user!
把300篇txt文件做成一个rc文件(里面格式是mytxt1 txt 1.abc mytxt2 txt 2.abc……),又把rc编译成res(a.res),然后做成dll(library Txt; {$R a.RES}begin end. ),最后用程序调用。下面是源代码,可就是不行,盼望告诉为什么,以及如何改正。谢谢。另外,如果加上第一行的‘stdcall;External'txt.dll'’还是不行。
procedure TForm1.Button1Click(sender :tobject);//stdcall;External 'txt.dll';
var
Hinst:THandle;
Htxt:THandle;
begin
Randomize();
key:=Random(299)+1;
Hinst:=Loadlibrary('txt.dll');
if Hinst=0 then ShowMessage('有错误了!找不到txt.dll。');
Htxt := LoadResource(Hinst, FindResource(Hinst, 'mytxt'+inttostr(key), 'txt'));
if Htxt<>0 then Form1.M1.Lines.Handle:=Htxt;
FreeLibrary(Hinst);
procedure TForm1.Button1Click(sender :tobject);//stdcall;External 'txt.dll';
var
Hinst:THandle;
Htxt:THandle;
begin
Randomize();
key:=Random(299)+1;
Hinst:=Loadlibrary('txt.dll');
if Hinst=0 then ShowMessage('有错误了!找不到txt.dll。');
Htxt := LoadResource(Hinst, FindResource(Hinst, 'mytxt'+inttostr(key), 'txt'));
if Htxt<>0 then Form1.M1.Lines.Handle:=Htxt;
FreeLibrary(Hinst);