Click here to Skip to main content
15,919,749 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Programmaticaly delete a file. Pin
vcseeker22-Jul-03 4:06
vcseeker22-Jul-03 4:06 
GeneralRe: Programmaticaly delete a file. Pin
melwyn22-Jul-03 5:02
melwyn22-Jul-03 5:02 
GeneralRe: Programmaticaly delete a file. Pin
basementman22-Jul-03 7:31
basementman22-Jul-03 7:31 
GeneralParsing .asp page Pin
Anonymous22-Jul-03 1:41
Anonymous22-Jul-03 1:41 
GeneralUser rights Pin
Hashim Saleem22-Jul-03 1:24
Hashim Saleem22-Jul-03 1:24 
GeneralRe: User rights Pin
Mazdak22-Jul-03 1:32
Mazdak22-Jul-03 1:32 
GeneralRe: User rights Pin
Anonymous22-Jul-03 5:22
Anonymous22-Jul-03 5:22 
GeneralRe: User rights Pin
Iain Clarke, Warrior Programmer22-Jul-03 5:27
Iain Clarke, Warrior Programmer22-Jul-03 5:27 
Here is a quick and dirty method to check whether the user *could* write to specific key
in HKLM I used for a setup program that did different levels of setup depending on the
authority of the user:

char    buf [MAX_PATH];

// First of all, is this an NT system?
{
    OSVERSIONINFO       osVer;
    osVer.dwOSVersionInfoSize = sizeof (osVer);
    GetVersionEx (&osVer);
    bIsNT = 1 && (osVer.dwPlatformId & VER_PLATFORM_WIN32_NT);
}

// If it is NT, are we admin enough to install Bus Files / Drivers?
bIsAdministrator = FALSE;
if (bIsNT)
{
    TRUSTEE Trustee;
    ACCESS_MASK AccessMask;
    ::BuildTrusteeWithName (&Trustee, "CURRENT_USER");

    // Can we edit registry device entries?
    PSECURITY_DESCRIPTOR    pSecDesc= NULL;
    PACL                    pAcl    = NULL;
    if (::GetNamedSecurityInfo (
        "MACHINE\\SYSTEM\\CurrentControlSet\\Services",
        SE_REGISTRY_KEY,
        DACL_SECURITY_INFORMATION,
        NULL,
        NULL,
        &pAcl,
        NULL,
        &pSecDesc) == ERROR_SUCCESS)
    {
        if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS)
        {
            if (AccessMask & STANDARD_RIGHTS_REQUIRED)
                bIsAdministrator = TRUE;
        }
        ::LocalFree (pSecDesc);
    }

    // Can we install to Winnt/System32/devices?
    if (!GetSystemDirectory (buf, MAX_PATH))
        bIsAdministrator = FALSE;
    else
    {
        ::lstrcat (buf, "\\drivers");
        sPathSystem = buf;
    }

    if (bIsAdministrator && ::GetNamedSecurityInfo (
        buf,
        SE_FILE_OBJECT,
        DACL_SECURITY_INFORMATION,
        NULL,
        NULL,
        &pAcl,
        NULL,
        &pSecDesc) == ERROR_SUCCESS)
    {
        if (::GetEffectiveRightsFromAcl (pAcl, &Trustee, &AccessMask) == ERROR_SUCCESS)
        {
            if (AccessMask & STANDARD_RIGHTS_REQUIRED)
                bIsAdministrator = TRUE;
        }
        ::LocalFree (pSecDesc);
    } else
        bIsAdministrator = FALSE;
}


This may give you a headstart, or at least things to search for in the Platform SDK.

Iain.
GeneralRe: User rights Pin
Hashim Saleem22-Jul-03 7:15
Hashim Saleem22-Jul-03 7:15 
GeneralRe: User rights Pin
Hashim Saleem22-Jul-03 22:00
Hashim Saleem22-Jul-03 22:00 
GeneralRe: User rights Pin
Iain Clarke, Warrior Programmer22-Jul-03 22:43
Iain Clarke, Warrior Programmer22-Jul-03 22:43 
QuestionHow to get Path of the Exe file Pin
Hashim Saleem22-Jul-03 0:47
Hashim Saleem22-Jul-03 0:47 
AnswerRe: How to get Path of the Exe file Pin
Mazdak22-Jul-03 0:55
Mazdak22-Jul-03 0:55 
GeneralRe: How to get Path of the Exe file Pin
Hashim Saleem22-Jul-03 1:18
Hashim Saleem22-Jul-03 1:18 
GeneralReduce the flicker of the dock window when resize Pin
Rajesh match21-Jul-03 23:46
Rajesh match21-Jul-03 23:46 
Generalsetting icon(120*40) to SDI Application left corner of the title Pin
Adi Narayana21-Jul-03 23:39
Adi Narayana21-Jul-03 23:39 
GeneralRe: setting icon(120*40) to SDI Application left corner of the title Pin
Jens Doose21-Jul-03 23:56
Jens Doose21-Jul-03 23:56 
GeneralRe: setting icon(120*40) to SDI Application left corner of the title Pin
Adi Narayana22-Jul-03 0:32
Adi Narayana22-Jul-03 0:32 
GeneralRe: setting icon(120*40) to SDI Application left corner of the title Pin
Jens Doose22-Jul-03 1:28
Jens Doose22-Jul-03 1:28 
GeneralRetrieving Header and Footer using VC++ Pin
adsilva21-Jul-03 23:32
adsilva21-Jul-03 23:32 
GeneralFAQ 8.4 Pin
Andrew Walker22-Jul-03 2:14
Andrew Walker22-Jul-03 2:14 
GeneralRe: FAQ 8.4 Pin
Ryan Binns22-Jul-03 5:41
Ryan Binns22-Jul-03 5:41 
GeneralRe: FAQ 8.4 Pin
Andrew Walker22-Jul-03 5:43
Andrew Walker22-Jul-03 5:43 
GeneralRe: Retrieving Header and Footer using VC++ Pin
David Crow22-Jul-03 4:57
David Crow22-Jul-03 4:57 
GeneralRe: Retrieving Header and Footer using VC++ Pin
adsilva25-Jul-03 19:20
adsilva25-Jul-03 19:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.