다음을 통해 공유


방법: 애플리케이션 시작 및 키 입력 보내기(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 클래스)가 필요합니다.

참고하십시오