하기 사이트에서 발췌... (감사합니다.)

http://blog.naver.com/sbspace?Redirect=Log&logNo=130163194983

 

 

프로젝트를 컴파일해서 나온 실행파일에 관리자권한을 주고 싶을 때가 있다. 예를 들어, C:\Program Files 또는 C:\Windows 에서 실행하고 그 안에서 파일쓰기나 수정을 하려면 반드시 관리자권한으로 실행해야하기 때문이다. 물론 실행파일을 우클릭하고 관리자권한으로 실행하기 메뉴를 선택하거나 속성-호환성에서 항상 관리자권한으로 실행되도록 할 수도 있다. 하지만 조금 번거로운 면이 있기 때문에 아예 실행파일에 관리자권한을 준 상태로 컴파일하는 방법을 이용하는 것도 좋다.

 

핵심은 프로젝트 속성 - 링커 - 매니페스트 파일 에서 사용자권한을 변경하면 된다. 변경하는 방법은 매니페스트 파일의 내용을 편집하면 된다. 다이얼로그 기반으로 임의의 프로젝트를 생성하면 "프로젝트명.exe.intermediate.manifest "라는 매니페스트 파일이 생긴다. 이것을 메모장이나 기타 에디터로 열면 대략 아래와 비슷한 내용이 있을 것이다. 이 중에서 하이라이트 표시한 부분을 주목하자. 기존에는 'asInvoker'로 되어있었는데 'requireAdministrator'로 수정하고 컴파일하니 실행파일에 작은 방패모양이 붙으면서 자동으로 관리자권한으로 실행할 수 있게 되었다.

 

 

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='requireAdministrator' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.DebugCRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.DebugMFC' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*' />
    </dependentAssembly>
  </dependency>
</assembly>

 

'프로그래밍 > VC++ 개발 코딩' 카테고리의 다른 글

바이트 정렬(Byte Alignment) pragma pack(1)  (0) 2015.11.20
DebugView 사용하기  (0) 2015.09.21
64bit Bit Shift  (1) 2015.09.14
mutex 사용하기  (0) 2014.10.28
WM_NCHITTEST 메세지  (0) 2014.04.30

+ Recent posts