> Dr Gerard Hammond at [EMAIL PROTECTED] wrote:
> Brilliant! Thanks Chris!
>
> Is anybody here willing to convert this into REALbasic ?
Aaron Ballman was recently asking for suggestions for his WFS. He's not on
the NUG but perhaps my bcc to him on this message will get him involved ;-)
Keith DeLong
> At 9:06 AM -0400 22/3/07, Chris Little wrote:
>> on 3/21/07 11:28 PM, Dr Gerard Hammond at [EMAIL PROTECTED] wrote:
>>
>>> Hi,
>>>
>>> Does anybody know how to change a Win32 file's permissions via RB code.
>>> I need to modify a file so that the Security tab has the "Full
>>> Control" checkbox ticked for *ALL USERS*
>>>
>>> using the shell I tried
>>>
>>> attrib -r thefilepath
>>>
>>> but that didn't work.
>>>
>>> Logging in as an administrator and doing it via the Properties panel
>>> works but my users struggle with this level of detail.
>>
>> Gerard,
>>
>> Here is some C++ code that does close to what you need. It is a snippet from
>> some code to give the Everyone group full access to a directory. It should
>> be straight forward to convert to declares with the help of the docs on
>> MSDN. You will still have to be logged in as a user with the rights to
>> change file/directory permissions for the file in question.
>>
>> Chris
>>
>> ACCESS_MODE aMode = GRANT_ACCESS ;
>> EXPLICIT_ACCESS aAccess ;
>> LPTSTR aPath = inDir->path ;
>> LPTSTR aTrustee = "Everyone" ;
>> PACL aOldACL ;
>> PACL aNewACL = NULL ;
>> PSECURITY_DESCRIPTOR aPSD = NULL ;
>> DWORD aErr = ERROR_SUCCESS;
>> DWORD aMask = ACTRL_FILE_WRITE | ACTRL_FILE_WRITE_PROP
>> | ACTRL_FILE_WRITE_ATTRIB | ACTRL_FILE_READ | ACTRL_FILE_READ_PROP |
>> ACTRL_FILE_READ_ATTRIB | ACTRL_FILE_APPEND | ACTRL_FILE_EXECUTE ;
>>
>> if (hAdvapi_DLL != NULL)
>> {
>> aErr = GetNamedSecurityInfo( aPath, SE_FILE_OBJECT,
>> DACL_SECURITY_INFORMATION, NULL, NULL, &aOldACL, NULL, &aPSD );
>>
>> if ( aErr == ERROR_SUCCESS)
>> {
>> BuildExplicitAccessWithName( &aAccess, aTrustee, aMask, aMode,
>> SUB_CONTAINERS_AND_OBJECTS_INHERIT ) ;
>>
>> aErr = SetEntriesInAcl( 1, &aAccess, aOldACL, &aNewACL ) ;
>>
>> if ( aErr == ERROR_SUCCESS )
>> {
>> aErr = SetNamedSecurityInfo( aPath, SE_FILE_OBJECT,
>> DACL_SECURITY_INFORMATION, NULL, NULL, aNewACL, NULL );
>> }
>>
>> if ( aNewACL != NULL )
>> {
>> AccFree( aNewACL ) ;
>> }
>> }
>>
>> if( aPSD != NULL)
>> {
>> AccFree( aPSD );
>> }
>>
>> aResult = ( aErr == ERROR_SUCCESS ) ;
>> }
>>
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>