この例では、 Shell メソッドを使用してメモ帳アプリケーションを起動し、 My.Computer.Keyboard.SendKeys メソッドを使用してキーストロークを送信して文を出力します。
例
Dim ProcID As Integer
' Start the Notepad application, and store the process id.
ProcID = Shell("NOTEPAD.EXE", AppWinStyle.NormalFocus)
' Activate the Notepad application.
AppActivate(ProcID)
' Send the keystrokes to the Notepad application.
My.Computer.Keyboard.SendKeys("I ", True)
My.Computer.Keyboard.SendKeys("♥", True)
My.Computer.Keyboard.SendKeys(" Visual Basic!", True)
' The sentence I ♥ Visual Basic! is printed on Notepad.
信頼性の高いプログラミング
要求されたプロセス識別子を持つアプリケーションが見つからない場合、 ArgumentException 例外が発生します。
.NET Framework のセキュリティ
Shell
関数の呼び出しには、完全信頼 (SecurityException クラス) が必要です。
こちらも参照ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET