Check Operations in Advance When Installing

[This is preliminary documentation and subject to change.]

Requirement  (Designed for Microsoft® Windows® Logo)

The installer must check before starting any operation to ensure that it can complete that operation. The following are requirements based on this principle:

Remarks

The following sample code checks for user privilege level.

//----------------------------------------------------------
// IsAdmin - tests to see if the current user is an admin
//----------------------------------------------------------

BOOL IsAdmin( )
{
    SC_HANDLE hSC;

// Try an Admin Privileged API - if it works, return TRUE, else FALSE
    hSC = OpenSCManager(
        NULL,
        NULL,
        GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE  );

    if ( hSC == NULL ) 
        return FALSE;
    CloseServiceHandle( hSC );
    return TRUE;
}

See Also

For more information about how to check the user privilege level, see KB article PSS ID# Q118626.