winexecshellexecuteCreateOleObject

解决方案 »

  1.   


    具体代码(打开光盘根目录):  ShellExecute(handle,nil,pchar('explorer'),pchar('\.'),nil,SW_SHOWNORMAL);
      

  2.   

    调用资源管理器显示光盘内容如楼上的。
    打开比如temp.doc如下:procedure TForm1.Button1Click(Sender: TObject);
    var
      Template,NewTemplate,ItemIndex:OleVariant;
    begin
       try
       Template := EmptyParam;
       NewTemplate := True;
       ItemIndex := 1;
       try
        Wordapplication1.Connect;
       except
        MessageDlg('Word may not be installed', mtError, [mbOk], 0);
        Abort;
       end;
       Wordapplication1.Visible := True;
       {Create new document}
       Template :='f:\temp.doc';
       if not FileExists(Template)
       then
       begin
         Application.MessageBox('文档模版位置有误','警告',MB_OK);
         WordApplication1.Quit;
         WordApplication1.Disconnect;
         exit;
       end;
       NewTemplate := False;
       WordApplication1.Documents.Add(Template, NewTemplate);
        {Assign WordDocument component}
       WordDocument1.ConnectTo(WordApplication1.Documents.Item(ItemIndex));
      except
        on E: Exception do
        begin
          ShowMessage(E.Message);
        end;
      end;
      WordApplication1.Disconnect;
    end;