Tested my game on Vista

Miscellaneous Forums/General Discussion/Tested my game on Vista

While googling for something about changing vista folder permissions programatically, I came across this code. I'm a bit busy at the moment, so I thought I'd post if here for anyone who wants to take a look at, and if no one's shown any interest or dismissed it as unhelpful, I'll have a proper look at it tomorrow hopefully.


LPTSTR FileName = "C:\\Temp\\MyDir";
    LPTSTR TrusteeName = "Everyone";

    DWORD AccessMask = GENREIC_READ | GENERIC_WRITE;
    ACCESS_MODE option = GRANT_ACCESS;
    DWORD InheritFlag = CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE;    
    EXPLICIT_ACCESS explicitaccess;


    PACL ExistingDacl;
    PACL NewAcl = NULL;
    PSECURITY_DESCRIPTOR psd = NULL;

    DWORD dwError;

    dwError = GetNamedSecurityInfo(
                        FileName,
                        SE_FILE_OBJECT,
                        DACL_SECURITY_INFORMATION,
                        NULL,
                        NULL,
                        &ExistingDacl,
                        NULL,
                        &psd
                        );

    BuildExplicitAccessWithName(
            &explicitaccess,
            TrusteeName,
            AccessMask,
            option,
            InheritFlag
            );

    //
    // add specified access to the object
    //

    dwError = SetEntriesInAcl(
            1,
            &explicitaccess,
            ExistingDacl,
            &NewAcl
            );

    //
    // apply new security to file
    //

    dwError = SetNamedSecurityInfo(
                    FileName,
                    SE_FILE_OBJECT, // object type
                    DACL_SECURITY_INFORMATION,
                    NULL,
                    NULL,
                    NewAcl,
                    NULL
                    );