■ 웹 페이지에서 프로그램을 실행하는 방법을 보여준다.
▶ chrome.reg (크롬 브라우저 사용시)
1 2 3 4 5 6 |
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome] "ExternalProtocolDialogShowAlwaysOpenCheckbox"=dword:00000001 |
▶ explorer.reg (인터넷 익스플로러 브라우저 사용시)
1 2 3 4 5 6 |
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\ProtocolExecute\samplesystem] "WarnOnOpen"=dword:00000000 |
▶ testproject.reg (실행 프로그램 등록)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\TestProject] @="URL:TestProject Protocol" "URL Protocol"="" [HKEY_CLASSES_ROOT\TestProject\DefaultIcon] [HKEY_CLASSES_ROOT\TestProject\shell] [HKEY_CLASSES_ROOT\TestProject\shell\Open] [HKEY_CLASSES_ROOT\TestProject\shell\Open\command] @="\"D:\\TestProject\\TestProject\\bin\\Debug\\net5.0-windows\\TestProject.exe\" \"%1\"" |
▶ testproject.html (웹 페이지)
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 |
<!DOCTYPE html> <html> <head> <title>TestProject 실행하기</title> <meta http-equiv="content-type" charset="utf-8"> </head> <script> function execute() { var target1 = document.getElementsByName("param1")[0].value; var target2 = document.getElementsByName("param2")[0].value; var target3 = document.getElementsByName("param3")[0].value; var target4 = document.getElementsByName("param4")[0].value; var target5 = document.getElementsByName("param5")[0].value; location.href = "TestProject:" + "/" + target1 + "/" + target2 + "/" + target3 + "/" + target4 + "/" + target5; } </script> <br> <form name="form" style="padding-left:20px"> 항목 1 : <input type="text" name="param1" value="서울"><p /> 항목 2 : <input type="text" name="param2" value="수원"><p /> 항목 3 : <input type="text" name="param3" value="대전"><p /> 항목 4 : <input type="text" name="param4" value="광주"><p /> 항목 5 : <input type="text" name="param5" value="대구"><p /> </form> <input type="button" name="summit" style="position:relative; left:20px; top:0px; height:30px; width:200px;" value="TestProject 실행" onclick="execute()"> |
▶ MainForm.cs
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 |
using System; using System.Windows.Forms; using System.Web; namespace TestProject { /// <summary> /// 메인 폼 /// </summary> public partial class MainForm : Form { //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - MainForm() /// <summary> /// 생성자 /// </summary> public MainForm() { InitializeComponent(); string[] argumentArray = Environment.GetCommandLineArgs(); if(argumentArray.Length > 1) { this.messageLabel.Text = HttpUtility.UrlDecode(argumentArray[1]); } } #endregion } } |