啟動相關 App程式開啟特殊檔案 zlyperson(原作)-Windows開發-.NET教程-

來源:互聯網
上載者:User
啟動相關 App程式開啟特殊檔案    zlyperson(原作)    
    
原文是C#,我把它改成了VB.但未來得及測試.若發現什麼問題請告之.
    這篇短文將示範如何啟動與特殊檔案關聯的應用程式來開啟特殊檔案,而不必知道相關 App程式的具體位置和名稱。比如,你要開啟demo.bmp,通常在Windows下是MSPaint.exe與之關聯的。VB.Net啟動相關 App程式開啟特殊檔案,需要用到.NetFrameWork System.Diagnostics命名空間。
下面,我們將構造一個任何關聯程式的啟動器,建一個VB檔案Starter.vb。
imports System;
imports System.IO;
imports System.Diagnostics;
public class Starter
     public shared sub new(args as string())
        '首先,建立進程啟動資訊的結構
        dim pInfo as new ProcessStartInfo();
        pInfo.UseShellExecute = true;
        dim i as integer
        for i = 0 to args.Length-1
    if File.Exists(args[i]) then
       pInfo.FileName = args[i];
       '啟動進程
       dim p as Process = Process.Start(pInfo);
    end if
        next
end sub
end class
編譯Starter.vb
執行Starter test.bmp test.xls
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.