Win32 API 日本語リファレンス
ホームSecurity › DestroyPrivateObjectSecurity

DestroyPrivateObjectSecurity

関数
プライベートオブジェクトのセキュリティ記述子を解放する。
DLLADVAPI32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// ADVAPI32.dll
#include <windows.h>

BOOL DestroyPrivateObjectSecurity(
    PSECURITY_DESCRIPTOR* ObjectDescriptor
);

パラメーター

名前方向
ObjectDescriptorPSECURITY_DESCRIPTOR*in

戻り値の型: BOOL

各言語での呼び出し定義

// ADVAPI32.dll
#include <windows.h>

BOOL DestroyPrivateObjectSecurity(
    PSECURITY_DESCRIPTOR* ObjectDescriptor
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DestroyPrivateObjectSecurity(
    IntPtr ObjectDescriptor   // PSECURITY_DESCRIPTOR*
);
<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DestroyPrivateObjectSecurity(
    ObjectDescriptor As IntPtr   ' PSECURITY_DESCRIPTOR*
) As Boolean
End Function
' ObjectDescriptor : PSECURITY_DESCRIPTOR*
Declare PtrSafe Function DestroyPrivateObjectSecurity Lib "advapi32" ( _
    ByVal ObjectDescriptor As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DestroyPrivateObjectSecurity = ctypes.windll.advapi32.DestroyPrivateObjectSecurity
DestroyPrivateObjectSecurity.restype = wintypes.BOOL
DestroyPrivateObjectSecurity.argtypes = [
    ctypes.c_void_p,  # ObjectDescriptor : PSECURITY_DESCRIPTOR*
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
DestroyPrivateObjectSecurity = Fiddle::Function.new(
  lib['DestroyPrivateObjectSecurity'],
  [
    Fiddle::TYPE_VOIDP,  # ObjectDescriptor : PSECURITY_DESCRIPTOR*
  ],
  Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn DestroyPrivateObjectSecurity(
        ObjectDescriptor: *mut *mut core::ffi::c_void  // PSECURITY_DESCRIPTOR*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool DestroyPrivateObjectSecurity(IntPtr ObjectDescriptor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_DestroyPrivateObjectSecurity' -Namespace Win32 -PassThru
# $api::DestroyPrivateObjectSecurity(ObjectDescriptor)
#uselib "ADVAPI32.dll"
#func global DestroyPrivateObjectSecurity "DestroyPrivateObjectSecurity" sptr
; DestroyPrivateObjectSecurity ObjectDescriptor   ; 戻り値は stat
; ObjectDescriptor : PSECURITY_DESCRIPTOR* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global DestroyPrivateObjectSecurity "DestroyPrivateObjectSecurity" sptr
; res = DestroyPrivateObjectSecurity(ObjectDescriptor)
; ObjectDescriptor : PSECURITY_DESCRIPTOR* -> "sptr"
; BOOL DestroyPrivateObjectSecurity(PSECURITY_DESCRIPTOR* ObjectDescriptor)
#uselib "ADVAPI32.dll"
#cfunc global DestroyPrivateObjectSecurity "DestroyPrivateObjectSecurity" intptr
; res = DestroyPrivateObjectSecurity(ObjectDescriptor)
; ObjectDescriptor : PSECURITY_DESCRIPTOR* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procDestroyPrivateObjectSecurity = advapi32.NewProc("DestroyPrivateObjectSecurity")
)

// ObjectDescriptor (PSECURITY_DESCRIPTOR*)
r1, _, err := procDestroyPrivateObjectSecurity.Call(
	uintptr(ObjectDescriptor),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DestroyPrivateObjectSecurity(
  ObjectDescriptor: Pointer   // PSECURITY_DESCRIPTOR*
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'DestroyPrivateObjectSecurity';
result := DllCall("ADVAPI32\DestroyPrivateObjectSecurity"
    , "Ptr", ObjectDescriptor   ; PSECURITY_DESCRIPTOR*
    , "Int")   ; return: BOOL
●DestroyPrivateObjectSecurity(ObjectDescriptor) = DLL("ADVAPI32.dll", "bool DestroyPrivateObjectSecurity(void*)")
# 呼び出し: DestroyPrivateObjectSecurity(ObjectDescriptor)
# ObjectDescriptor : PSECURITY_DESCRIPTOR* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。