Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Vista UAC: The Definitive Guide

, 21 Mar 2008
Learn how UAC operates behind the scenes. Use the Elevate package to start multiple elevated processes but only display one UAC elevation dialog from a non-elevated process.
elevate_binariesanddocs.zip
Elevate.dll
Elevate.exe
elevate_demo.zip
Elevate.dll
Elevate.exe
TestChild.exe
TestParent.exe
elevate_src.zip
#include "CoreLib.h"
//#include <vld.h>

int main(int argc, char **argv, char **envp)
{
  GxApp.Init(argc, argv, envp);

  BString TempData;
  Process TempProcess;
  Process::ProcessData TempProcessData;

  TempData = System::AppDirectory("") + "TestChild.exe";

  if (!TempProcessData.Extract(TempData))
  {
    printf("Error extracting information.\n");

    return 1;
  }

  // Run the TestChild process with forced elevation,
  // waiting for it to complete,
  // attached to this console,
  // and pipe stderr to internal buffers.
  if (!TempProcess.StartProcess(TempProcessData.Command, TempProcessData.Argv, TempProcessData.Envp, TempProcessData.Directory, BString(), Process::Foreground, Process::Standard, Process::Piped, Process::NoDetachProcess, Process::ForceElevate))
  {
    printf("Error running process.\n");

    return 1;
  }

  // Data should have come across the named pipe for stderr.
  printf("Data from TestChild.exe:  \"%s\"", *TempProcess.ReadStderr());

  return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Thomas Hruska
Web Developer
United States United States
Been writing software for a really long time - something like 18 years. Started on the TI/99-4A, moved to the Tandy 1000, and somehow managed to skip all the lousy hardware/software jumps (286, 386, first Pentiums, Win95, etc.)
 
I now run a small software business called CubicleSoft with a few products you might be interested in. VerifyMyPC and MyUpdate Toolkit are the most popular. I'm also the author of a book called "Safe C++ Design Principles".

| Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 22 Mar 2008
Article Copyright 2007 by Thomas Hruska
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid