2013-07-12 47 views
1

在表單加載上,您可以從Environment.CommandLine檢索整個命令字符串。但是,當我使用應用程序事件來檢測命令行字符串時,我的單個實例應用程序再次打開,我找不到相當於Environment.CommandLineStartupNextInstanceEventArgsVB.NET等效於(StartupNextInstanceEventArgs)中的Environment.CommandLine

這裏是我的代碼:

Private Sub MyApplication_StartupNextInstance(_ 
    ByVal sender As Object, _ 
    ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs _ 
) Handles Me.StartupNextInstance 
     'I can only use e.CommandLine which returns a readonlycollection, not a string like Environment.CommandLine does. Can someone help me out? 
     End Sub 
+0

只需使用'昏暗CMD =的string.join(」」,e.CommandLine.ToArray)' –

回答

3

從MSDN My.Application.StartupNextInstance Event

必須使用e參數的的CommandLine屬性來訪問以後嘗試的參數來啓動一個實例應用。 My.Application.CommandLineArgs屬性提供用於啓動單實例應用程序的第一個實例的參數。

所以只需使用somethihg像:

For Each arg As String in e.CommandLine 
    Debug.WriteLine(arg) 
Next