次の方法で共有


方法: アプリケーションを起動してキーストロークを送信する (Visual Basic)

この例では、 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 クラス) が必要です。

こちらも参照ください