我要做一个程序,功能很简单,就是完成一个功能:当我点击一个按钮的时候,会自动去启动IE,并且在IE里面输入我要显示的一个固定的地址,请大家给出代码,谢谢!
昨天我提过这个问之后,大家教了我两个方法,一个是用WinExec函数,一个是用ShellExecute函数,但是好像WinExec需要绝对路径,不能在其他机器上通用,而ShellExecute确是从现有的打开的IE里面去打开,我想的是每次都重新打开一个IE,请大家再指教一把。

解决方案 »

  1.   

    shellExecute(Handle, 'open','http://www.csdn.net',nil,nil, SW_SHOWNORMAL);
      

  2.   

    为什么不想读注册表呢?总比一个磁盘一个磁盘的查找iexplore.exe是否存在好吧而且万一机子是双系统呢?这个办法也行不通的。所以读注册表也未尝不是个办法吧。
      

  3.   

    uses Registry, StrUtils;//将这两个包uses上,然后放个button,运行我下面的程序试看看procedure TForm1.Button1Click(Sender: TObject);
    var
     reg : TRegistry;
     iepath: string;
    begin
      try
        reg:=TRegistry.Create;
        reg.RootKey:=HKEY_LOCAL_MACHINE;
        reg.OpenKey('\SOFTWARE\Classes\Applications\iexplore.exe\shell\open\command',false);
        iepath:=reg.ReadString('');
      finally
        reg.Free;
      end;  iepath:= rightstr(iepath,length(iepath)-1);
      iepath:= leftstr(iepath,pos('"',iepath)-1);
      winexec(PChar(iepath+' www.sohu.com'),SW_SHOW);
    end;
      

  4.   

    // 在Uses处加入 shellapi procedure TForm1.Button1Click(Sender: TObject);
    begin
      shellExecute(Handle, 'open','http://www.hao123.com',nil,nil, SW_SHOWNORMAL);
    end;