我想在delphi中实现打开*.doc *.ppt *.htm *.Txt文件,就象在资源管理器中用鼠标双击一样,启动相应的浏览工具word、PowerPoint、IE、PatNode

解决方案 »

  1.   

    判断文件的扩展名,然后起用相应的应用程序如下:
    var
      fileName: string;
    begin
      fileName := UpperCase(ExtraxtFileEx(OpenDialog1.FileName));
      if fileName = '.DOC' then
        winExec('winword.exe '+OpenDialog1.fileName, SW_SHOWNORMAL)
      else if fileName = '.ppt' then
        winExec('POWERPNT.EXE '+OpenDialog1.fileName, SW_SHOWNORMAL)
      else if fileName = '.HTM' then
        winExec('IExplore.exe '+Opendialog1.fileName, SW_SHOWNORMAL)
      ELSE IF FILEnAME = '.TXT' then
        winExec('Notepad.exe '+Opendialog1.fileName, SW_SHOWNORMAL);
    END;
      
         
      

  2.   

    直接用ShellExectue()函数就行了。