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

DSEditSecurity

関数
ディレクトリオブジェクトのセキュリティ編集ダイアログを表示する。
DLLDSSEC.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

HRESULT DSEditSecurity(
    HWND hwndOwner,
    LPCWSTR pwszObjectPath,
    LPCWSTR pwszObjectClass,
    DWORD dwFlags,
    LPCWSTR pwszCaption,
    PFNREADOBJECTSECURITY pfnReadSD,   // optional
    PFNWRITEOBJECTSECURITY pfnWriteSD,   // optional
    LPARAM lpContext
);

パラメーター

名前方向
hwndOwnerHWNDin
pwszObjectPathLPCWSTRin
pwszObjectClassLPCWSTRin
dwFlagsDWORDin
pwszCaptionLPCWSTRin
pfnReadSDPFNREADOBJECTSECURITYinoptional
pfnWriteSDPFNWRITEOBJECTSECURITYinoptional
lpContextLPARAMin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DSEditSecurity(
    HWND hwndOwner,
    LPCWSTR pwszObjectPath,
    LPCWSTR pwszObjectClass,
    DWORD dwFlags,
    LPCWSTR pwszCaption,
    PFNREADOBJECTSECURITY pfnReadSD,   // optional
    PFNWRITEOBJECTSECURITY pfnWriteSD,   // optional
    LPARAM lpContext
);
[DllImport("DSSEC.dll", ExactSpelling = true)]
static extern int DSEditSecurity(
    IntPtr hwndOwner,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] string pwszObjectPath,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pwszObjectClass,   // LPCWSTR
    uint dwFlags,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pwszCaption,   // LPCWSTR
    IntPtr pfnReadSD,   // PFNREADOBJECTSECURITY optional
    IntPtr pfnWriteSD,   // PFNWRITEOBJECTSECURITY optional
    IntPtr lpContext   // LPARAM
);
<DllImport("DSSEC.dll", ExactSpelling:=True)>
Public Shared Function DSEditSecurity(
    hwndOwner As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> pwszObjectPath As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pwszObjectClass As String,   ' LPCWSTR
    dwFlags As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pwszCaption As String,   ' LPCWSTR
    pfnReadSD As IntPtr,   ' PFNREADOBJECTSECURITY optional
    pfnWriteSD As IntPtr,   ' PFNWRITEOBJECTSECURITY optional
    lpContext As IntPtr   ' LPARAM
) As Integer
End Function
' hwndOwner : HWND
' pwszObjectPath : LPCWSTR
' pwszObjectClass : LPCWSTR
' dwFlags : DWORD
' pwszCaption : LPCWSTR
' pfnReadSD : PFNREADOBJECTSECURITY optional
' pfnWriteSD : PFNWRITEOBJECTSECURITY optional
' lpContext : LPARAM
Declare PtrSafe Function DSEditSecurity Lib "dssec" ( _
    ByVal hwndOwner As LongPtr, _
    ByVal pwszObjectPath As LongPtr, _
    ByVal pwszObjectClass As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal pwszCaption As LongPtr, _
    ByVal pfnReadSD As LongPtr, _
    ByVal pfnWriteSD As LongPtr, _
    ByVal lpContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DSEditSecurity = ctypes.windll.dssec.DSEditSecurity
DSEditSecurity.restype = ctypes.c_int
DSEditSecurity.argtypes = [
    wintypes.HANDLE,  # hwndOwner : HWND
    wintypes.LPCWSTR,  # pwszObjectPath : LPCWSTR
    wintypes.LPCWSTR,  # pwszObjectClass : LPCWSTR
    wintypes.DWORD,  # dwFlags : DWORD
    wintypes.LPCWSTR,  # pwszCaption : LPCWSTR
    ctypes.c_void_p,  # pfnReadSD : PFNREADOBJECTSECURITY optional
    ctypes.c_void_p,  # pfnWriteSD : PFNWRITEOBJECTSECURITY optional
    ctypes.c_ssize_t,  # lpContext : LPARAM
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DSSEC.dll')
DSEditSecurity = Fiddle::Function.new(
  lib['DSEditSecurity'],
  [
    Fiddle::TYPE_VOIDP,  # hwndOwner : HWND
    Fiddle::TYPE_VOIDP,  # pwszObjectPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pwszObjectClass : LPCWSTR
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # pwszCaption : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pfnReadSD : PFNREADOBJECTSECURITY optional
    Fiddle::TYPE_VOIDP,  # pfnWriteSD : PFNWRITEOBJECTSECURITY optional
    Fiddle::TYPE_INTPTR_T,  # lpContext : LPARAM
  ],
  Fiddle::TYPE_INT)
#[link(name = "dssec")]
extern "system" {
    fn DSEditSecurity(
        hwndOwner: *mut core::ffi::c_void,  // HWND
        pwszObjectPath: *const u16,  // LPCWSTR
        pwszObjectClass: *const u16,  // LPCWSTR
        dwFlags: u32,  // DWORD
        pwszCaption: *const u16,  // LPCWSTR
        pfnReadSD: *const core::ffi::c_void,  // PFNREADOBJECTSECURITY optional
        pfnWriteSD: *const core::ffi::c_void,  // PFNWRITEOBJECTSECURITY optional
        lpContext: isize  // LPARAM
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DSSEC.dll")]
public static extern int DSEditSecurity(IntPtr hwndOwner, [MarshalAs(UnmanagedType.LPWStr)] string pwszObjectPath, [MarshalAs(UnmanagedType.LPWStr)] string pwszObjectClass, uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string pwszCaption, IntPtr pfnReadSD, IntPtr pfnWriteSD, IntPtr lpContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DSSEC_DSEditSecurity' -Namespace Win32 -PassThru
# $api::DSEditSecurity(hwndOwner, pwszObjectPath, pwszObjectClass, dwFlags, pwszCaption, pfnReadSD, pfnWriteSD, lpContext)
#uselib "DSSEC.dll"
#func global DSEditSecurity "DSEditSecurity" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DSEditSecurity hwndOwner, pwszObjectPath, pwszObjectClass, dwFlags, pwszCaption, pfnReadSD, pfnWriteSD, lpContext   ; 戻り値は stat
; hwndOwner : HWND -> "sptr"
; pwszObjectPath : LPCWSTR -> "sptr"
; pwszObjectClass : LPCWSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; pwszCaption : LPCWSTR -> "sptr"
; pfnReadSD : PFNREADOBJECTSECURITY optional -> "sptr"
; pfnWriteSD : PFNWRITEOBJECTSECURITY optional -> "sptr"
; lpContext : LPARAM -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "DSSEC.dll"
#cfunc global DSEditSecurity "DSEditSecurity" sptr, wstr, wstr, int, wstr, sptr, sptr, sptr
; res = DSEditSecurity(hwndOwner, pwszObjectPath, pwszObjectClass, dwFlags, pwszCaption, pfnReadSD, pfnWriteSD, lpContext)
; hwndOwner : HWND -> "sptr"
; pwszObjectPath : LPCWSTR -> "wstr"
; pwszObjectClass : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; pwszCaption : LPCWSTR -> "wstr"
; pfnReadSD : PFNREADOBJECTSECURITY optional -> "sptr"
; pfnWriteSD : PFNWRITEOBJECTSECURITY optional -> "sptr"
; lpContext : LPARAM -> "sptr"
; HRESULT DSEditSecurity(HWND hwndOwner, LPCWSTR pwszObjectPath, LPCWSTR pwszObjectClass, DWORD dwFlags, LPCWSTR pwszCaption, PFNREADOBJECTSECURITY pfnReadSD, PFNWRITEOBJECTSECURITY pfnWriteSD, LPARAM lpContext)
#uselib "DSSEC.dll"
#cfunc global DSEditSecurity "DSEditSecurity" intptr, wstr, wstr, int, wstr, intptr, intptr, intptr
; res = DSEditSecurity(hwndOwner, pwszObjectPath, pwszObjectClass, dwFlags, pwszCaption, pfnReadSD, pfnWriteSD, lpContext)
; hwndOwner : HWND -> "intptr"
; pwszObjectPath : LPCWSTR -> "wstr"
; pwszObjectClass : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; pwszCaption : LPCWSTR -> "wstr"
; pfnReadSD : PFNREADOBJECTSECURITY optional -> "intptr"
; pfnWriteSD : PFNWRITEOBJECTSECURITY optional -> "intptr"
; lpContext : LPARAM -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dssec = windows.NewLazySystemDLL("DSSEC.dll")
	procDSEditSecurity = dssec.NewProc("DSEditSecurity")
)

// hwndOwner (HWND), pwszObjectPath (LPCWSTR), pwszObjectClass (LPCWSTR), dwFlags (DWORD), pwszCaption (LPCWSTR), pfnReadSD (PFNREADOBJECTSECURITY optional), pfnWriteSD (PFNWRITEOBJECTSECURITY optional), lpContext (LPARAM)
r1, _, err := procDSEditSecurity.Call(
	uintptr(hwndOwner),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszObjectPath))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszObjectClass))),
	uintptr(dwFlags),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszCaption))),
	uintptr(pfnReadSD),
	uintptr(pfnWriteSD),
	uintptr(lpContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DSEditSecurity(
  hwndOwner: THandle;   // HWND
  pwszObjectPath: PWideChar;   // LPCWSTR
  pwszObjectClass: PWideChar;   // LPCWSTR
  dwFlags: DWORD;   // DWORD
  pwszCaption: PWideChar;   // LPCWSTR
  pfnReadSD: Pointer;   // PFNREADOBJECTSECURITY optional
  pfnWriteSD: Pointer;   // PFNWRITEOBJECTSECURITY optional
  lpContext: NativeInt   // LPARAM
): Integer; stdcall;
  external 'DSSEC.dll' name 'DSEditSecurity';
result := DllCall("DSSEC\DSEditSecurity"
    , "Ptr", hwndOwner   ; HWND
    , "WStr", pwszObjectPath   ; LPCWSTR
    , "WStr", pwszObjectClass   ; LPCWSTR
    , "UInt", dwFlags   ; DWORD
    , "WStr", pwszCaption   ; LPCWSTR
    , "Ptr", pfnReadSD   ; PFNREADOBJECTSECURITY optional
    , "Ptr", pfnWriteSD   ; PFNWRITEOBJECTSECURITY optional
    , "Ptr", lpContext   ; LPARAM
    , "Int")   ; return: HRESULT
●DSEditSecurity(hwndOwner, pwszObjectPath, pwszObjectClass, dwFlags, pwszCaption, pfnReadSD, pfnWriteSD, lpContext) = DLL("DSSEC.dll", "int DSEditSecurity(void*, char*, char*, dword, char*, void*, void*, int)")
# 呼び出し: DSEditSecurity(hwndOwner, pwszObjectPath, pwszObjectClass, dwFlags, pwszCaption, pfnReadSD, pfnWriteSD, lpContext)
# hwndOwner : HWND -> "void*"
# pwszObjectPath : LPCWSTR -> "char*"
# pwszObjectClass : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# pwszCaption : LPCWSTR -> "char*"
# pfnReadSD : PFNREADOBJECTSECURITY optional -> "void*"
# pfnWriteSD : PFNWRITEOBJECTSECURITY optional -> "void*"
# lpContext : LPARAM -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。