개발/윈도우
ShellExecute API 사용방법
-=HaeJuK=-
2010. 5. 31. 09:45
728x90
반응형
ShellExecute() 사용 방법
API 함수명 : ShellExecute();
제공 DLL : SHELL.DLL
프로그램을 띄우거나 파일을 실행할경우 ShellAPI 함수인 ShellExecute() 를 사용합니다.
이 함수는 윈도우즈 탐색기에서 파일을 선택하고 더블클릭하는 기능과 동일한 동작을 합니다.
다음은 ShellExecute() 의 몇가지 사용예입니다.
예제 Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/******************************************************************************
* _ _ _ _ __ _____ _ _
*| | | | | | | |/ / | __ \ | | | |
*| |__| | __ _ ___ | |_ _| ' / | | | | _____ __ | | __ _| |__
*| __ |/ _` |/ _ \_ | | | | | < | | | |/ _ \ \ / / | | / _` | '_ \
*| | | | (_| | __/ |__| | |_| | . \ | |__| | __/\ V / | |___| (_| | |_) |
*|_| |_|\__,_|\___|\____/ \__,_|_|\_\ |_____/ \___| \_(_) |______\__,_|_.__/
*
* Copyright (c) HaeJuK Dev Lab All Rights Reserved.
*
*******************************************************************************/
//(1) 파일과 연관(association)된 프로그램으로 파일을 엽니다
ShellExecute(Handle, 'open', 'test.txt', nil, nil, SW_SHOW);
//(2) notepad.exe 에 파라미터로 config.sys 파일을 주어 메모장을 실행합니다
ShellExecute(Handle, 'open', 'notepad', 'c:\config.sys', nil, SW_SHOW);
//(3) PC에 설치된 기본 웝브라우저로 지정한 사이트를 엽니다.
ShellExecute(Handle, 'open', 'www.google.co.kr', nil, nil, SW_SHOW);
//(4) 특정 폴더를 시작 폴더로 하는 윈도우즈 탐색기를 엽니다
ShellExecute(Handle, 'explore', 'c:\windows', nil, nil, SW_SHOW);
//(5) readme.doc 파일을 연결된 프로그램으로 인쇄하고 화면을 닫습니다
ShellExecute(Handle, 'print', 'readme.doc', nil, nil, SW_SHOW);
//(6) rMyDelphiFile.pas 파일을 wordpad 프로그램으로 인쇄하고 화면을 닫습니다
ShellExecute(Handle, 'print', 'wordpad.wxe', 'MyDelphiFile.pas', nil, SW_SHOW);
//(7) 기본 메일 프로그램을 실행합니다.
ShellExecute(Handle, nil, 'mailto:babo@gmail.com', nil, nil, SW_SHOW);
//(8) DOS 명령어를 실행하고 화면을 닫습니다
ShellExecute(Handle, 'open', 'command.com', '/c copy file1.txt file2.txt', nil, SW_SHOW);
//(9) DOS 명령어를 실행하고 화면을 닫지 않습니다
ShellExecute(Handle, 'open', 'command.com', '/k dir', nil, SW_SHOW);
|
cs |
728x90