Introduction
This experiment is intended to help you learn how to add your applications to the running level of Vista.
Purpose
- This experiment allows you to customize the running level of any program.
Procedure
1-ensure that Vista UAC is enabled
- First click VistaStartMenu, select Start MenuTopCurrentUser iconAnd click:
- SelectTurn User Account Control on or off:
- In the dialog box, make sure thatUse User Account Control (UAC) to help protect your computerCheck box is selected:
If this item is not selected, click Select item and then clickOKButton and restart the computer
Step 2-
Create a Windows form application
- OpenVs 2008, SelectFile->New->Project... :
- In the displayed Project Creation wizard, selectVisual C #->Windows->Windows Forms Application:
- Enter the project nameVistalogodemoAnd clickOKButton to create a project:
- Here, our program is built here. We mainly experience the definition of the Vista running level. Here, click the debug button for debugging:
Procedure
3-add an embedded Custom Level for the program in vs2008 so that the program has the administrator privilege to run
- CreateText Files, And name it"Executable File Name. EXE. manifest", Here we write it"Vistalogodemo.exe. manifest", Paste the following content into the file:
Code
<? XML version = "1.0" encoding = "UTF-8" standalone = "yes"?>
<Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1" manifestversion = "1.0">
<Assemblyidentity version = "1.0.0.0" processorarchitecture = "x86" name = "vistalogodemo" type = "Win32"/>
<Description> description of your application </description>
<! -- Identify the application security requirements. -->
<Trustinfo xmlns = "urn: Schemas-Microsoft-com: ASM. V3">
<Security>
<Requestedprivileges>
<Requestedexecutionlevel level = "requireadministrator" UIAccess = "false"/>
</Requestedprivileges>
</Security>
</Trustinfo>
</Assembly>
There are three running levels here. Here, we use requireadministrator to run with the Administrator permission. If it is written as aslnvoker, it runs with normal permissions.
- Store this file to the project's"Bin \ debug"Directory:
- Return to the program solution and selectSolution BrowserClick Show All files at the top of the page:
- OpenBinDirectoryDebugDirectoryVistalogodemo.exeFile:
- After opening the file, the tree list of the EXE file is displayed:
- InListUpperRight-clickSelectAdd Resource:
- In the displayed dialog box, selectImport:
- InFile selection dialog boxSelect all files from the filter box:
- Then selectVistalogodemo.exe. manifestFile and clickOpenButton:
- This is in the pop-upDialog BoxInResource TypeInputRt_manifest, As shown below, and clickOKButton:
- ReturnVistalogodemo.exeFile tree list, find the resource you just addedRt_manifest:
- When the value is101NodeRight-clickSelectProperties,Set itsIDAttributeChange1:
- Set the value1 [neutral]NodeDelete:
- Save the EXE file:
- Run the application in the bin \ DEBUG directory of the Project. By default, the program runs as administrator:
-------------------------------------------
Wu Huifeng
Wilson Wu