Results 1 to 2 of 2

Thread: Need UAC Centre Screen - NOT as Flashing Icon on Taskbar

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2011

    Question Need UAC Centre Screen - NOT as Flashing Icon on Taskbar

    I am running Visual Studio 2013 under Win 8 and moving my project from VB6 to

    When the user clicks on a file with one of my extensions (eg "myfile.msct") it asks the user to approve changes by calling the UAC window

    It works fine BUT the UAC appears only as a flashing Icon on the Taskbar - how do I ensure it appears right in the middle of the Screen (the user could easily miss that the taskbar is flashing as it is not particularly noticeable and fooled me at first)

    Many thanks

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2011

    Re: Need UAC Centre Screen - NOT as Flashing Icon on Taskbar

    Well, this is actually discussed here at length:

    It seems that:

    "Background applications will automatically prompt the user for elevation on the taskbar, rather than automatically switching to the secure desktop for elevation. The elevation prompt will appear minimized on the taskbar and will blink to notify the user that an application has requested elevation. An example of a background elevation occurs when a user browses to a Web site and begins downloading an installation file. The user then goes to check e-mail while the installation downloads in the background. Once the download completes in the background and the install begins, the elevation is detected as a background task rather than a foreground task. This detection prevents the installation from abruptly stealing focus of the user's screen while the user is performing another task--reading e-mail. This behavior creates a better user experience for the elevation prompt.

    However, some foreground applications currently prompt as background applications on Windows Vista. This behavior is the result of an absent parent HWND. In order to ensure that Windows Vista acknowledges your application as a foreground application, you must pass a parent HWND with a ShellExecute, CoCreateInstanceAsAdmin, or managed code call.

    The UAC elevation mechanism uses the HWND as part of determining whether the elevation is a background or foreground elevation. If the application is determined to be a background application, the elevation is placed on the taskbar as a blinking button. The user must click on the button, as with any application requesting foreground access, before the elevation will continue. Not passing the HWND will result in this occurring even though the application might actually have foreground.

    The following code sample illustrates how to pass HWND with ShellExecute:

    BOOL RunAsAdmin( HWND hWnd, LPTSTR lpFile, LPTSTR lpParameters )
        ZeroMemory ( &sei, sizeof(sei) );
        sei.cbSize          = sizeof(SHELLEXECUTEINFOW);
        sei.hwnd            = hWnd;
        sei.fMask           = SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI;
        sei.lpVerb          = _TEXT("runas");
        sei.lpFile          = lpFile;
        sei.lpParameters    = lpParameters;
        sei.nShow           = SW_SHOWNORMAL;
        if ( ! ShellExecuteEx ( &sei ) )
            printf( "Error: ShellExecuteEx failed 0x%x\n", GetLastError() );
            return FALSE;
        return TRUE;
    I had a go at this in C++ but you then need to define the Structure SHELLEXECUTEINFO and the thing grows like Topsy and it showed all the signs of turning into a saga.

    Anybody done this in

    [Edite: at the point the user clicks on a file, my exe is NOT running so I guess that altering my code would not make any difference ... unless maybe, my exe runs FIRST but the user may just navigate to a file and click on it without initially having run the exe ...]
    Last edited by wavering; Dec 16th, 2014 at 07:15 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width