[英]How do you add command line switches to VB.NET WinForms application (when run from CMD)?
我正在創建一個基於 GUI 的應用程序 (VB.NET); 我希望它在從命令行運行而不顯示 GUI 時具有開關(例如-s
、 -r
、 -a
等)。
我已經嘗試了很多方法,但它們都不起作用,即使是微軟自己的方法。
請幫我。 我已經研究了一天。
將您的啟動表單設置為.visible = false
。
然后在Form_Load
事件中:
' Loop through the passed arguments
For Each argument As String In My.Application.CommandLineArgs
' Do stuff. i.e.:
if argument = "-s" then
' Do something
End if
if argument = "-r" then
' Do something
End if
if argument = "-a" then
' Make the form visible
Me.Visible = True
End if
Next
此外,如果您打算從不使用 GUI,只需制作控制台應用程序而不是 winforms 應用程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.