我需要更改文件的所有权或撤消使用Powerbuilder创建文件的用户的所有权。即在我的应用程序中,用户创建了一个文件,我想立即在代码中从文件中删除他的所有权。这样用户就无法编辑或修改文件。我发现了一些相同的c ++样本(Change file owner in Windows),但无法在Powerbuilder中复制它。调用SetNamedSecurityInfoW时,使用以下代码获取错误代码87。如果有人可以帮助我使用Powerbuilder实现所有权更改。
CONSTANT Integer SE_FILE_OBJECT = 1
CONSTANT Integer OWNER_SECURITY_INFORMATION = 1
CONSTANT Integer NAME_SIZE = 64
CONSTANT Integer SID_SIZE = 32
String domain_name
Integer ret, sid_len, domain_len
integer li_ret, newowner
n_filesys nvo
Integer l_nothing
SetNull(l_nothing)
newowner = 100
li_ret = nvo.SetNamedSecurityInfoW('P:\My Documents\Test.txt',SE_FILE_OBJECT,OWNER_SECURITY_INFORMATION,newowner,l_nothing,l_nothing,l_nothing)
If li_ret <> 0 Then
messagebox("Hi","Error")
end if
---------------------------------------------------------------------
Declaration of SetNamedSecurityInfoW:---
Function Integer SetNamedSecurityInfo ( &
String ObjectName, &
Integer ObjectType, &
Integer SecurityInfo, &
Long sidOwner, &
Long sidGroup, &
Long Dacl, &
Long Sacl &
) Library "advapi32.dll"
答案 0 :(得分:1)
根据list of Windows system error codes,您的参数无效。我的猜测是sidOwner,sidGroup,Dacl和Sacl参数。这些都是结构的指针,因此最好实际定义结构并通过引用传递它们。为sidOwner传递一个整数肯定会导致问题。声明结构看起来也不是很直接,但您可以开始使用the documentation here。