Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registry access error in vb2008

Status
Not open for further replies.

SrikanthRayabhagi

Technical User
May 19, 2008
1
0
0
Hi everyone.. I got some real trouble in Vista while accessing the Registry through Visual Basic 2008..I am a real beginner of VB and I need someone's help please help me on this matter..
The example for this issue is HOW TO CHANGE THE SYSTEM IP ADDRESS THROUGH MY APPLICATION
 
I'm sorry I can't remember where I found this so I can't credit the author but certainly helped me. Vista is much more secure so permissions are more important. Anyway here's the extract......

=====================================================

Using Manifests to Elevate an application in Vista
Problem and the Solution

Problem: An application we are developing needs to always ask for Admin elevation (even for standard users) to run properly. If the users are standard users, then we need to have the UAC popup with the standard edits to ask for Admin Username and Password. If the user is already an admin and has UAC enabled, it needs to ask for permission to run.

Solution: Once we have your application developed (say MyApp.exe), we need to write a manifest file and either embed that onto the MyApp.exe or include it along with the application to make sure that the application, on Vista, always prompts the user for Admin credentials.

A simple Manifest will look something like this:

--------------------------------------------------------------------------------

<?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>
</assembly>


--------------------------------------------------------------------------------

Ways of the Manifest

Now, as I said there are two ways in which this manifest can be used:

Shipping the manifest file along with the application
The manifest can be placed along-side the application in the folder in which the application exists by naming the manifest as MyApp.exe.manifest. Vista will automatically apply the manifest file if it doesn't find one embedded in the application. This is one of the ways in which an application can be made forward compatible; by releasing a patch which will just ship-in the manifest file and place it at the location where the application resides.

Embedding the manifest IN the application
We can also embed the manifest file in the .exe file itself by executing the mt.exe tool provided as part of the Visual Studio 2005 SDK.The following steps need to be performed in sequence:
Open up the command prompt (in elevated mode, if using Vista)
Traverse to the directory which contains your MyApp.exe
Make sure that the MyApp.exe.manifest is placed in the same directory (It easily if you do so, once the mt.exe completes successfully, you can remove it from the folder)
Run this command:
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\mt.exe" -manifest "MyApp.exe.manifest" -outputresource:"MyApp.exe";#1
(including the #1, which specifies that the outputresource is an executable and not a library DLL. If you want to do this for a library DLL, replace the #1 with #2)
Make sure that there are no errors thrown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top