FredAI Posted July 20, 2011 Posted July 20, 2011 Hi all.I'm trying to convert this function to AutoIt. I don't see any error, but it always return 87 (Invalid parameter in winerror.h) when I test.Any ideas?Thanks.Fredexpandcollapse popupGlobal Const $DACL_SECURITY_INFORMATION = 4 Global Const $OWNER_SECURITY_INFORMATION = 1 Global Const $GROUP_SECURITY_INFORMATION = 2 Global Const $SACL_SECURITY_INFORMATION = 8 Global Const $SE_SACL_PROTECTED = 8192 Global Const $SE_DACL_PROTECTED = 4096 Local $File = @ScriptDir&'\ND.txt' Local $R = _WINAPI_SetNamedSecurityInfo($File,-1,$SE_DACL_PROTECTED) If IsArray($R) Then For $i = 0 To 7 MsgBox(0,'',$R[$i]) Next EndIf Func _WINAPI_SetNamedSecurityInfo( $pObjectName, _ $SE_OBJECT_TYPE, _ $SECURITY_INFORMATION, _ $psidOwner = '', _ $psidGroup = '', _ $pDacl = '', _ $pSacl = '' _ ) If $SE_OBJECT_TYPE = -1 Then $SE_OBJECT_TYPE = 'SE_FILE_OBJECT' Return DllCall('advapi32.dll', 'DWORD','SetNamedSecurityInfoW', _ 'str',$pObjectName, _ 'str',$SE_OBJECT_TYPE, _ 'int',$SECURITY_INFORMATION, _ 'ptr',$psidOwner, _ 'ptr',$psidGroup, _ 'ptr',$pDacl, _ 'ptr',$pSacl _ ) EndFunc My UDFs: SetAcl permissions | System restore Examples: File version info editor | GetIp() improved Programs: UVK - Ultra virus killer | ExeFixer | Recent file seeker | SHIcon | Quick_Any2Ico
Mat Posted July 21, 2011 Posted July 21, 2011 You are using 'str' as the type string but calling the unicode version of the function. Try: Return DllCall('advapi32.dll', 'DWORD','SetNamedSecurityInfoW', _ 'wstr',$pObjectName, _ 'wstr',$SE_OBJECT_TYPE, _ 'int',$SECURITY_INFORMATION, _ 'ptr',$psidOwner, _ 'ptr',$psidGroup, _ 'ptr',$pDacl, _ 'ptr',$pSacl _ ) You are also passing those pointers as strings by default, that shouldn't stop it working but standard practice is using zero instead. AutoIt Project Listing
FredAI Posted August 1, 2011 Author Posted August 1, 2011 Thanks, Mat. It still doesn't work. I guess I'll have to create the structures ant use a valid pointer. Right now I'm too busy to continue with this project. As you may have guessed, I want to create an Autoit code replacement for setacl.exe. I'll post back when I come back to this project. Thanks again. My UDFs: SetAcl permissions | System restore Examples: File version info editor | GetIp() improved Programs: UVK - Ultra virus killer | ExeFixer | Recent file seeker | SHIcon | Quick_Any2Ico
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now