winexec('c:\110.txt',sw_normal);
为什么打不开外部这个文本呢。应该是怎么的啊。

解决方案 »

  1.   


    function ExeAFile(s:string):integer;
    var
      ShellExecInfo: TShellExecuteInfo;
    begin
      if s<> '' then
      begin
        {initialize params}
        ZeroMemory(@ShellExecInfo, SizeOf(TShellExecuteInfo));
        with ShellExecInfo do
        begin
          cbSize := SizeOf(TShellExecuteInfo);
    //      Wnd := Application.Handle;
          Wnd := 0;
          lpFile := PChar(s);
          nShow:=SW_SHOW;
        end;
      ShellExecuteEx(@ShellExecInfo);
      end;
    result:=0;
    end;
    ExeAFile('c:\110.txt');
      

  2.   

    WinExec只能对Exe文件有用了。 
    用shellExecuteuses ShellApi;shellexecute(handle,'open','c:\110.exe','','',sw_shownormal);
      

  3.   

    uses shellApiShellExecute(hwnd,'open','c:\110.txt',nil,nil,Sw_Normal);
      

  4.   

    CreateProcess..不过这个函数相对比较复杂点....
      

  5.   

    uses shellApiShellExecute(hwnd,'open','c:\110.txt',nil,nil,Sw_Normal);
    这个好用的!
      

  6.   

    longtusoft(神灯之主) 说得很正确,winexe()不会用关联的软件打开文件,而shellexecute()则可以
      

  7.   

    ShellExecute没有那么复杂:
    ShellExecute(nil, nil, 'c:\110.txt', nil, nil, SW_SHOW);足够了。
      

  8.   

    搞错了,是:ShellExecute(0, nil, 'c:\110.txt', nil, nil, SW_SHOW);足够了。
      

  9.   

    用WinExec也不是不可啊!WinExec('notepad c:\110.txt',SW_Normal);
      

  10.   

    同意linzhisong(無聊) WinExec只能对Exe文件有用了。 
    用shellExecuteuses ShellApi;shellexecute(handle,'open','c:\110.exe','','',sw_shownormal);