给分!!!关于DLL中执行其他程序的问题!! (50分)

  • 主题发起人 至尊王
  • 开始时间
如果内存分配问题,
在 exe 和 dll 中都 uses ShareMem 不知道有没有关系
 
ShellExecute(0,'open','notepad.exe',PChar('http://nettv.diy.163.com/bug.htm'),nil,sw_shownormal)看看,一样,参数传不过来!
 
我也做一下看看吧!
 
是的,在Dll中好像就不行!
 
在EXE中调用就没问题
 
可以的,很正常

DLL:

library dllTest;

uses
SysUtils,
Classes,shellapi;
const SW_SHOWNORMAL=1;
{$R *.RES}
procedure MyExe;stdCall;
begin
ShellExecute(0,'open',pchar('d:/temp/delphi/test.exe'),PChar('http://nettv.diy.163.com/bug.htm'),nil,SW_SHOWNORMAL)
end;
exports
MyExe;
end.


DLL调用的EXE能接受到参数:Test.exe
//cmdline 和 ParamStr(1) 中都有参数
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
showmessage(inttostr(ParamCount));
showmessage(cmdline);
for i := 0 to ParamCount do showmessage(ParamStr(i));
end;



另一个程序,调用DLL中的EXE,Project1.exe

procedure MyExe;stdcall;external 'd:/dllTest.dll';
procedure TForm1.Button1Click(Sender: TObject);
begin
myexe;
end;
 
你在DLL中使用
ShellExecute(0,'open','notepad.exe',PChar('http://nettv.diy.163.com/bug.htm'),nil,sw_shownormal)看看,一样,参数传不过来!
 
忘了说了,我这个是ActiveX Dll
 
那就很可能是OLE没有初始的问题
// DLL 和 EXE 单元文件 End. 前加上以下的初始化
initialization
oleinitialize(nil);
finalization
oleuninitialize;
 
我已经解决了,不能用Shell...我把分给你!谢谢那一刀!
 
那一刀只一个UP就值40分???????????????????
 
顶部