Registry 를 수정하는 Application 을 제작하였다.
기존에는 VisualStudio 의 UAC 를 상승시켜 사용을 하다보니 UnauthorizedAccessException 을 만나지 않았었다.


그래서 기존에 제작한 Application 의 UAC 를 상승시켜야만 했다.



UAC 를 상승시키는 한가지 방법으로 실행파일의 Manifest 를 사용하는 방법이 있다.
이방법을 사용하기위해선 Manifest 파일과 mt.exe 파일을 사용해야만 하는데 먼저 manifest 파일을 보게되면
대략 아래와 같다.

    1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

    2 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">

    3   <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>

    4   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">

    5     <security>

    6       <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

    7         <requestedExecutionLevel level="asInvoker" uiAccess="false"/>

    8       </requestedPrivileges>

    9     </security>

   10   </trustInfo>

   11 </assembly>


이 파일에서 requestedExecuteionLevel 의 level 값이 중요한데 기본적으로 "asInvoker" 로 되어 있다.
이 값은 UAC 상승없이 실행하며 호출 Process 의 권한을 이용하도록 되어있다.
따라서 나같은 경우 Application 의 Debug 가 VisualStudio 의 UAC 를 바탕으로 실행이 되었으므로 UAC 가 상승되어 있는 상태였으므로 맘대로 Registry 를 건드릴수 있었던 것이다.

다른 값으로 "highestAvailable" 이 있는데 이것은 호출 Process 가 가지고 있는 권한 중 가장 높은 권한을 사용하는 옵션이다.

여기서 내가 사용할 값은 "requireAdministrator" 으로 실행시 관리자 권한으로 UAC 상승을 요청하도록 하는 옵션인데 따라서 확인창이 뜨게 된다.

내가 사용하는 방법을 간단히 소개를 했는데...
위 방법을 사용하려면 먼저 manifest 파일을 얻어야 한다.
간단히 얻는 방법이 있다.

woojja.exe 의 실행파일인 경우 실행파일이 컴파일되는 Target Folder 에 가보면 ("bin" Folder 에 "Debug", "Release" Folder)
woojja.vshost.exe.manifest 라는 파일이 보일 것이다.
ㅋㅋㅋ 이것을 사용하자.
파일을 복사하여 "woojja.exe.manifest" 라는 이름의 파일로 만들자...
그리고 파일을 열어
requestedExecuteionLevel 의 level 값을 "asInvoker" 에서 "requireAdministrator" 로 수정하자.
저장하고...

이제 mt.exe 를 실행시켜야 할 것이다.


mt.exe 파일의 위치는
"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin"
에 있다.
Version 에 따라
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin" 에도 존재한다.

이제 실행시키자.

실행파일(exe)인 경우 옵션값 1 을 사용한다.
mt.exe -manifest "woojja.exe.manifest" -outputresource:"woojja.exe";#1

Library 파일(dll)의 경우 옵션값 2 를 사용한다.
mt.exe -manifest "woojja.dll.manifest" -outputresource:"woojja.dll";#2



 

D:\wizExpert\Source\woojja\Deploy>"C:\Program Files\Microsoft SDKs\Windows\v7.0A\

bin\mt.exe" -manifest "woojja.exe.manifest" -outputresource:"woojja.exe";#1

Microsoft (R) Manifest Tool version 5.2.3790.2076

Copyright (c) Microsoft Corporation 2005.

All rights reserved.

 

D:\wizExpert\Source\woojja\Deploy>

 

 



그러면 요로케 나올 것이며...

아래와 같이 UAC 확인창이 뜰 것이다.





^^
행복한 고수되셔요...
woojja ))*
\\\\\\\\\\\\\\\\\\\\\\\\\\\
반응형

캬캬캬
엄청나게 무식하다고 욕하지 마시라...

기존 Resources 에 포함되어 있는 Resource 들을 보면 아래 와 같은 이미지들이 포함되어 있습니다.
번호로되어있는 파일들이 보일텐데요...


그 Resource 들을 파일 이름으로 조회를 해야할 일이 발생했습니다.
xml 데이터를 이용해서 imageList 객체를 만들려고 하는데 먼저 imageList 객체에 image 를 어떻게 추가할 수 있는지 MSDN Document 를 찾아보면...

 

.

Paramenter 를 보면 string 형의 Key 값과 Bitmap 형의 image 가 필요한데...
Key 는 XML 파일에서 가져오고... XML 에 있는 데이터를 바탕으로 Resource 에 등록되어 있는 이미지를 가져올 계획이었다.

참고로 XML 파일에는 이런식으로 되어 있다.

   15   <PlayerTypes>

   16     <PlayerType category="Default" value ="0" enable="True" Default="True">Transparent</PlayerType>

   17     <PlayerType category="Normal" value ="10" enable="True">일반-검정</PlayerType>

   18     <PlayerType category="Normal" value ="11" enable="True">일반-파랑</PlayerType>

   19     <PlayerType category="Normal" value ="12" enable="True">일반-빨강­</PlayerType>

   20     <PlayerType category="Normal" value ="13" enable="True">일반-초록</PlayerType>

   21     <PlayerType category="Normal" value ="14" enable="True">일반-하늘색</PlayerType>

   22     <PlayerType category="PopUp" value ="20" enable="False">팝업-검정</PlayerType>

   23     <PlayerType category="PopUp" value ="21" enable="False">팝업-파랑</PlayerType>

   24     <PlayerType category="PopUp" value ="22" enable="False">팝업-빨강­</PlayerType>

   25     <PlayerType category="PopUp" value ="23" enable="False">팝업-초록</PlayerType>

   26     <PlayerType category="PopUp" value ="24" enable="False">팝업-하늘색</PlayerType>

   27     <PlayerType category="SimpleCircle" value ="30" enable="True">단순 원형-파랑</PlayerType>

   28     <PlayerType category="SimpleCircle" value ="31" enable="True">단순 원형-빨강­</PlayerType>

   29     <PlayerType category="SimpleCircle" value ="32" enable="True">단순 원형-검정</PlayerType>

   30     <PlayerType category="SimpleSquare" value ="40" enable="True">단순 사각-파랑</PlayerType>

   31     <PlayerType category="SimpleSquare" value ="41" enable="True">단순 사각-빨강­</PlayerType>

   32     <PlayerType category="SimpleSquare" value ="42" enable="True">단순 사각-검정</PlayerType>

   33   </PlayerTypes>


그렇다면 이제 Assembly 에 있는 Resource 에 접근하는 방법을 알아봐야 할텐데...
"Show All Files" 아이콘을 클릭하면 숨겨져 있는 파일을 모두 볼수 있는데.. Assembly 전체에서 사용하는 Resources.resx 의 Designer code 파일을 보도록 하자...(Resources.Designer.vb)

 



이 파일을 열어보면... 아래와 같이 Resource 들을 접근하기위한 Property 가 주~~욱 나열되어 있는 것을 확인할 수 있다.

   63         Friend ReadOnly Property _10() As System.Drawing.Bitmap

   64             Get

   65                 Dim obj As Object = ResourceManager.GetObject("_10", resourceCulture)

   66                 Return CType(obj,System.Drawing.Bitmap)

   67             End Get

   68         End Property

   69 

   70         Friend ReadOnly Property _11() As System.Drawing.Bitmap

   71             Get

   72                 Dim obj As Object = ResourceManager.GetObject("_11", resourceCulture)

   73                 Return CType(obj,System.Drawing.Bitmap)

   74             End Get

   75         End Property

   76 

   77         Friend ReadOnly Property _12() As System.Drawing.Bitmap

   78             Get

   79                 Dim obj As Object = ResourceManager.GetObject("_12", resourceCulture)

   80                 Return CType(obj,System.Drawing.Bitmap)

   81             End Get

   82         End Property

   83 

   84         Friend ReadOnly Property _13() As System.Drawing.Bitmap

   85             Get

   86                 Dim obj As Object = ResourceManager.GetObject("_13", resourceCulture)

   87                 Return CType(obj,System.Drawing.Bitmap)

   88             End Get

   89         End Property


이 파일은 어떤 녀석이 만들어 주느냐?


위 그림처럼... Resources.resx 파일을 클릭해보면 아래 Properties 창에 "Custom Tool" 이라는 항목이 나오는데...
값을 보면... VbMyResourcesResXFileCodeGenerator 라는 녀석이 있는데...
바로 이녀석이 자동적으로 Generating 해주는 역할을 한다.
이 녀석이 Resource 의 이름. 즉, String 을 건네주면 값을 반환하는 Function 같은 것을 지원해주면 좋으련만...
그런 함수를 지원하지 않기 때문에...
내가 손으로 직접 만들어 주려고 한다. ㅋㅋㅋ

그럴려면...
VisualBasic.NET 의 경우 Resource 에 어떻게 접근할까?
위에서 봤듯이... Custome Tool 에 의해서 쉽게 접근 할 수 있다..

VisualBasic.Net 의 경우 My Namespace 를 사용하면 쉽게? 접근할 수 있는데...

Dim img As System.Drawing.Image = My.Resources._10

이런식으로 하면 바로 이미지를 가져올 수 있다.

하지만 나는 XML 파일의 String 값을 기반으로 실행을 하려고 했으므로...

 VbMyResourcesResXFileCodeGenerator 라는 녀석이 만들어낸 "Resources.Designer.vb" 파일을 참고삼아..
모듈을 만들고 몸뚱이에... 함수를 추가하여 엇비슷하게 사용할까 한다. ㅋㅋㅋ
(완전 단순 무식... ^^')

그 단순무식의 실체는 아래와 같다...
ㅋㅋㅋ

    1 Option Strict On

    2 Option Explicit On

    3 

    4 Imports System

    5 

    6 Namespace My.Resources

    7 

    8     <Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _

    9      Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _

   10      Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _

   11      Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _

   12     Module Resources_Partial

   13 

   14         Private resourceMan As Global.System.Resources.ResourceManager

   15 

   16         Private resourceCulture As Global.System.Globalization.CultureInfo

   17 

   18         '''<summary>

   19         '''  Returns the cached ResourceManager instance used by this class.

   20         '''</summary>

   21         <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _

   22         Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager

   23             Get

   24                 If Object.ReferenceEquals(resourceMan, Nothing) Then

   25                     Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("woojjaApplication.Resources", GetType(Resources).Assembly)

   26                     resourceMan = temp

   27                 End If

   28                 Return resourceMan

   29             End Get

   30         End Property

   31 

   32         '''<summary>

   33         '''  Overrides the current thread's CurrentUICulture property for all

   34         '''  resource lookups using this strongly typed resource class.

   35         '''</summary>

   36         <Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _

   37         Friend Property Culture() As Global.System.Globalization.CultureInfo

   38             Get

   39                 Return resourceCulture

   40             End Get

   41             Set(ByVal value As Global.System.Globalization.CultureInfo)

   42                 resourceCulture = value

   43             End Set

   44         End Property

   45 

   46         Public Function GetBitmapByName(ByVal strName As String) As System.Drawing.Bitmap

   47 

   48             Dim obj As Object = ResourceManager.GetObject(strName, resourceCulture)

   49             Return CType(obj, System.Drawing.Bitmap)

   50 

   51         End Function

   52 

   53         Public Function GetStringByName(ByVal strName As String) As String

   54 

   55             Dim obj As Object = ResourceManager.GetObject(strName, resourceCulture)

   56             Return CType(obj, String)

   57 

   58         End Function

   59 

   60     End Module

   61 End Namespace

   62 



GetBitmapByName() 과 GetStringByName() 이라는 함수가 추가된 것을 볼 수 있을 것이다.

함수의 Parameter에 strName 과 Type 을 던지는 것도 한가지 방법일 것이다.

그건 여러분이 선택할 사항이고... ㅋㅋ

Reflection 을 사용하여 원하는 값을 가져올 수도 있겠지만...
그 정도로 값을 동적으로 가져와야 할 사항은 아닌 까닭에 한번 만들어 보았다. ^^;



행복한 고수되십시요...


woojja ))*
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\



반응형
HTML 4 Vs HTML 5

둘의 차이점을 알기위해서 반드시 먼저 짚고 넘어가야할 주제가 있다.

그것은...

바로 Contents Model  이다.

HTML 5 이전의 HTML 문서는 <div>, <p>, <h1>, <h2>... Tag 와 같은 Block Level Element 와 <img>, <input>, <i>, <b> Tag 와 같은 Inline Element 로 구분되어지는 Tag 들로 구성되어 두 종류의 Tag 들을 적절히 사용하여 표현하였다.
그리고 이러한 Tag 들은 Tree 형태의 계층구조를 이루어 문서의 OutLine 을 구성하고 그 구조를 따라 Contents 에 접근할 수 있다.(JavaScript 나 CSS 에서 특정 Element 에 접근하는 방식을 떠올린다면 이해가 쉬우리라...)

HTML 5 문서 또한 다르지 않다.
하지만 HTML 5 는 "Contents Model" 이라는 새로운 개념을 추가하여 문서의 Outline 을 잡고 Contents 를 구성하게 된다.
HTML 5 는 기존의 Tag 에
한마디로 HTML 5 는 구성에 중점을 둔 구조라고 할 수 있겠다.
따라서 기존 DOM Tree 계층구조에서의 Contents 접근이 아닌 구성에 따라서 접근이 가능하게 되었다.(<Header>, <Footer>, <article> Tag 를 떠올려 보라. DOM Tree 를 따라갈 필요없이 곧바로 Contents 에 접근이 가능하다.-<Header>, <Footer>, <article> 과 같은 Tag 를 아직 모르시는 분께 죄송... 하지만 곧바로 다음에서 다루겠다. 일단은 그런게 있구나 식으로만이라도...>)
이런 이유로 HTML 5 의 Element들은 추가되었고, 기존의 HTML 보다 훨씬 더 Sementic 한 Web을 구성 할 수 있게 되었다는데에 집중해야 할 것이다.

따라서, 이제 우리는 HTML 5 의 각 Tag(Element)가 갖는 역할과 의미를 확실히 이해하여 Content Model 에 적합한 HTML 문서를 작성할 수 있도록 한층 더 많은 생각을 해야할 것이다.

HTML 5 에서는 아래 그림과 같이 Contents 의 종류에 따라 Element 들을 분류하고 있다.

Contents 는 다음과 같이 분류한다.
1. Metadata Contents
2. Flow Contents
3. Sectioning Contents
4. Heading Contents
5. Phrasing Contents
6. Embedded Contents
7. Interactive Contents


다음은 위 분류에 대해 간단히 설명해 보았다.
Category
설명
Tag
 Metadata Content  나머지 Contents 의 Presentation 이나 behavior를 설정하거나 현재문서와 다른 문서와의 관계를 설정. 또는, 기타 "Out Of Band"정보를 전달한다.  base, command, link, meta, noscript, script, style, title
 Flow Content  문서와 Application 의 Body 에서 사용되는 대부분의 Element들은 Flow Content 로 분류된다. a, abbr, address, area (map 요소의 자손인 경우) , article, aside, audio, b, bdi, bdo, blockquote, br, button, canvas, cite, code, command, datalist, del, details, dfn, div, dl, em, embed, fieldset, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, i, iframe, img, input, ins, kbd, keygen, label, map, mark, math, menu, meter, nav, noscript, object, ol, output, p, pre, progress, q, ruby, s, samp, script, section, select, small, span, strong, style (scoped 속성이 있으면) , sub, sup, svg, table, textarea, time, ul, var, video, wbr, Text
 Sectioning Content  Headings 와 Footers 의 범위를 정의한다.  article, aside, nav, section
 Heading Content  Section 의 Header 를 정의한다.  h1, h2, h3, h4, h5, h6, hgroup
 Phrasing Content  문서의 Text 이다. 또한 그 Text 를 intra-paragraph Level 로 Markup 하는 Element 이다.  a (구문 컨텐츠만을 포함하는 경우) , abbr, area (map 요소의 자손인 경우) , audio, b, bdi, bdo, br, button, canvas, cite, code, command, datalist, del (구문 컨텐츠만을 포함하는 경우) , dfn, em, embed, i, iframe, img, input, ins (구문 컨텐츠만을 포함하는 경우) , kbd, keygen, label, map (구문 컨텐츠만을 포함하는 경우) , mark, math, meter, noscript, object, output, progress, q, ruby, s, samp, script, select, small, span, strong, sub, sup, svg, textarea, time, var, video, wbr, Text
 Embedded Content  문서에 다른 Resource 를 삽입하는 Content 이다.  audio, canvas, embed, iframe, img, math, object, svg, video
 Interactive Content  사용자의 상호작용을 위해 특별하게 의도된 Content 이다.  a, audio (controls 속성이 있으면) , button, details, embed, iframe, img (usemap 속성이 있으면) , input (type 속성이 Hidden 상태가 “아니면”) , keygen, label, menu (type 속성이 toolbar 상태면) , object (usemap 속성이 있으면), select, textarea, video (controls 속성이 있으면)

자세한 내용은 http://www.whatwg.org/specs/web-apps/current-work/multipage/content-models.html 를 참고하시길...


다음은 위 내용을 바탕으로 변화된 HTML 5 의 모습을 살펴보기로 하겠다.

 


<참고>
앞서가는 디자이너와 퍼블리셔를 위한 HTML5 & CSS
철저해설 HTML 5
http://www.whatwg.org/specs/web-apps/current-work/multipage/index.html#contents
http://www.clearboth.org/html5/





행복한 고수되십시요...


woojja ))*
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
반응형

'Web > HTML 5' 카테고리의 다른 글

[HTML 5] 5. Sementic Element (2)  (1) 2011.06.01
[HTML 5] 4. Sementic Element (1)  (0) 2011.05.29
[HTML 5] 3. HTML4 vs HTML5 (2)  (0) 2011.05.11
[HTML 5] 1. HTML 5 의 개요  (2) 2011.05.09
[HTML 5] HTML 5 is... (2)  (2) 2011.05.08

+ Recent posts