一些文件都有Windows默认的打开程序,如*.mp3的默认打开程序是Winnap,*.jpg的默认打开程序是ACD,但是如何在delphi中确定一个文件的默认打开程序,并调用该程序打开文件?

解决方案 »

  1.   

    uses shellapi;
     ShellExecute(handle,'open','c:\test.jpg',nil,nil,SW_SHOWNORMAL);
      

  2.   

    Wi n E x e c ( ' N o t e P a d ' , S W _ R E S TORE); // 运行写字本procedure TForm1.Button1Click(Sender: TO b j e c t ) ;
    v a r
    S t a r t u p I n f o : T S t a r t u p I n f o ;
    P r o c e s s I n f o : T P r o c e s s I n f o r m a t i o n ;
    b e g i n
    // 初始化工作
    F i l l C h a r ( S t a r t u p I n f o , S i z e o f ( S t a r t u p I n f o ) , # 0 ) ;
    StartupInfo.cb := Sizeof(StartupInfo);
    StartupInfo.dwFlags := STA RT F _ U S E S H O W W I N D O W;
    C r e a t e P r o c e s s ( n i l ,
    'Calc', // 运行计算器
    n i l ,
    n i l ,
    f a l s e ,
    C R E ATE_NEW_CONSOLE or
    N O R M A L _ P R I O R I T Y _ C L A S S ,
    n i l ,
    n i l ,
    S t a r t u p I n f o ,
    P r o c e s s I n f o ) ;
    end;
      

  3.   

    uses shellapi;
     ShellExecute(handle,'open','c:\test.jpg',nil,nil,SW_SHOWNORMAL);