티스토리 뷰
무슨 설명이 필요하리까.
현재 PC의 권한 상태를 확인하고
관리자가 아니면 관리자권한으로 상승시키고 해당 윈폼을 실행시킨다.
만약 이렇게 처리해주지 않는다면 항상 확인 창이 뜨겠지. 관리자권한이 필요합니다~~~ 뭐 이런식으로.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using System.Security.Principal;
namespace Hysco_Widget
{
static class Program
{
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
bool administrator = _isAdministrator();
if(!administrator)
{
System.Diagnostics.ProcessStartInfo processInfo = new System.Diagnostics.ProcessStartInfo(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
// MessageBox.Show(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
processInfo.UseShellExecute = true;
processInfo.Verb = "runas";
Process.Start(processInfo);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
private static bool _isAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
}
'프로그래밍 > .NetFramework' 카테고리의 다른 글
| WorkBook 을 이용해서 GridView 엑셀로 내려받기 (0) | 2012.04.23 |
|---|---|
| EXCEL2010(엑셀2010) 읽기 Workbook 이용 (엑셀읽기) (0) | 2012.04.13 |
| 강력한코드그룹 삭제 및, 클릭원스 온라인배포 프로그램 삭제방법 (0) | 2012.04.04 |
| MessageBox의 버튼 텍스트 변경하기 (0) | 2012.04.04 |
| 닷넷프레임워크 삭제 유틸리티 (0) | 2012.03.16 |
- Total
- Today
- Yesterday
- rowspan
- Excel
- drag&drop
- CSS
- WebApi
- JavaScript
- SVG
- 자바스크립트
- grid
- 제이쿼리
- Style
- jquery chart
- Chart
- radius
- Mobile
- JS
- jQuery
- jQuery Mobile
- WCF
- IE
- html5
- MSSQL
- 프로시저
- ASP.NET
- json
- Ajax
- workbook
- 셀렉터
- css3
- 저장프로시저
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |