From: Jackie on 21 Jun 2010 13:33 Matti Vuori wrote: > I have for some time experienced locked files even though no process would > need to access the files. > > But after I added to all my file access routines a loop to retry writing, > deleting etc. for a couple times, in a second or two it would always > succeed... I think the Windows API really should have built-in support for > retries, but as it does not, the programmer must implement it. > > _Perhaps_ the same thing could help in this case. This sounds like a good idea to, no matter if it helps or not. :) -- Regards, Jackie
From: Jackie on 22 Jun 2010 07:57 Jackie wrote: > I can try to have a look through my code a bit later so I can't give you > an instant answer right now. I had a look and it seemed like I borrowed code from here: http://support.microsoft.com/kb/165194 It's a bit too much for me to make a small example for you. Sorry. I am sure you can find other pages that shows you exactly how to do it. I'll make an attempt to tell you the most important some steps: GetUserObjectSecurity - Get security descriptor for the file GetSecurityDescriptorDacl - Get DACL from security descriptor InitializeSecurityDescriptor - Create new security descriptor GetSecurityDescriptorDacl - Get DACL from new security descriptor GetAclInformation - Get size of the ACL information * Calculate the new ACL size InitializeAcl - Initialize new ACL GetAce and AddAce - Loop through existing ACEs and add them to the new one AddAccessAllowedAce - Add specified access for your SID SetSecurityDescriptorDacl - Set new DACL for the new security descriptor SetUserObjectSecurity - Set the new security descriptor for your file (handle to an opened file)? Haven't had a lot of experience with this so I can't really tell if this is going to work or if it's the best way, but I *think* that's about it at least. I have done it pretty much the same way in an earlier project but not with file (I just assume it's the same). It's quite a bit of code here for such a small thing that takes only one line of text to do with an external command line program. Exactly what I just "love": Recreating the wheel. :) -- Regards, Jackie
From: Jackie on 22 Jun 2010 08:19 Jackie wrote: > I'll make an attempt to tell you the most important some steps: > ... Oh.. Right.. You talked about *taking ownership*.. My mistake. So maybe it will be a little different in that case. -- Regards, Jackie
First
|
Prev
|
Pages: 1 2 Prev: Tell if the process is running in a Guest account Next: ANN: Seed7 Release 2010-06-20 |