advapi32.dll - File permissions

Archives Forums/Win32 Discussion/advapi32.dll - File permissions

ozzi789(Posted 2010) [#1]
Hi

I am writting a Backup tool, everything works well, but as you know, BB's CopyFile does not care about File permissions.

I found out that the Library "advapi32" does such stuff.

SetFileSecuirty
http://msdn.microsoft.com/en-us/library/aa379577%28VS.85%29.aspx

and

GetFileSecurity
http://msdn.microsoft.com/en-us/library/aa446639%28VS.85%29.aspx#


my decls looks like this
.lib "advapi32.dll"
GetFileSecurityA%(lpFileName*, info% ):"GetFileSecurityA"


So im trying to use that function like this:
f_string$=("D:\liste.xls")
len_f_string=Len(f_string$)
len_f_string=len_f_string+1
Print len_f_string



fh=CreateBank(len_f_string)
For i= 0 To len_f_string-1
	PokeByte(fh,i,Chr(Mid(f_string$,1,1)))
Next 


 

GetFileSecurityA%(fh, 1)




But i dont get it to work at all.
So my question is, does anybody know the WinApi good?
Could you please help me, im new to this stuff and i am pretty lost.


Thank you very much, greetings
ozzi


_PJ_(Posted 2010) [#2]
Tip:

use <code> or <codebox> tags around oyur code, using [ and ]instead of < and > :)

----

I can't offer much help, except for
GetFileSecurityA%(fh, 1)


This seems to be returning a value. So you may want to check that with
Sec%=GetFileSecurityA%(fh, 1)
Print Str(Sec%)


Also, someone with more knowledge than me may be able to clarify, but I am not sure if passing the bytes for the filepath is the way to give the file to the function. You may need to use a separate dll function to get the file as a handle or something first???


ozzi789(Posted 2010) [#3]
Hi

Ok sorry i will use that next time.
Yeah i forgot, but i knew that it returns a value, but it did never work properly, for they are some optional parameters that i dont really understand.

I made a little workaround, using the tool fileacl, it does just the same ;)

Somebody told me to pass the bytes like that, i think that should be correct...

Anyway, thanks for your time :)