My.Application 物件
更新:2007 年 11 月
提供與目前應用程式相關的屬性、方法和事件。
備註
My.Application 物件所公開 (Expose) 的屬性會傳回只與目前應用程式或 DLL 關聯的資料。使用 My.Application 無法改變任何系統層級資訊。
部分成員只適用於 Windows Form 或主控台應用程式 (Console Application)。
範例
這個範例使用 My.Application.CommandLineArgs 屬性,檢查應用程式的命令列引數。如果找到以 /input= 開頭的引數,則會顯示此引數的其餘部分。
Private Sub ParseCommandLineArgs()
Dim inputArgument As String = "/input="
Dim inputName As String = ""
For Each s As String In My.Application.CommandLineArgs
If s.ToLower.StartsWith(inputArgument) Then
inputName = s.Remove(0, inputArgument.Length)
End If
Next
If inputName = "" Then
MsgBox("No input name")
Else
MsgBox("Input name: " & inputName)
End If
End Sub
需求
命名空間 (Namespace)︰Microsoft.VisualBasic.ApplicationServices
類別 (Class):WindowsFormsApplicationBase (基底類別 (Base Class) ConsoleApplicationBase 提供可以在主控台應用程式中使用的成員,且基底類別 ApplicationBase 提供可以在所有專案中使用的成員)
組件:Visual Basic 執行階段程式庫 (在 Microsoft.VisualBasic.dll 中)
請參閱
參考
My.Application.ApplicationContext 屬性
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase