2013-05-18 61 views

回答

3

你可以做的是在程序啓動時讀取程序中的命令行參數,然後解析這些輸入來做出決定。

例如:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 

    Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs 

    If (String.Compare(CommandLineArgs(0), "-picture") = 0) Then 
     'desired code to do something for a picture here 

    ElseIf (String.Compare(CommandLineArgs(0), "-music") = 0) Then 
     'desired code to do something for music here 

    End If 

End Sub 

如果給輸入-music C:\文件路徑\ FILENAME.MP3然後CommandLineArgs(0)。將-music和CommandLineArgs(1)將C:\文件路徑\ FILENAME.MP3。從這裏你可以將CommandLineArgs(1)傳遞給你選擇的另一個程序來播放這個文件(或者使用一些內置的方法來播放它)。

+1

正是!謝謝。 – user2397435