EqualDomainSid
関数2つのSIDが同じドメインに属するかどうかを判定する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
BOOL EqualDomainSid(
PSID pSid1,
PSID pSid2,
BOOL* pfEqual
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pSid1 | PSID | in |
| pSid2 | PSID | in |
| pfEqual | BOOL* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
BOOL EqualDomainSid(
PSID pSid1,
PSID pSid2,
BOOL* pfEqual
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool EqualDomainSid(
IntPtr pSid1, // PSID
IntPtr pSid2, // PSID
out int pfEqual // BOOL* out
);<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EqualDomainSid(
pSid1 As IntPtr, ' PSID
pSid2 As IntPtr, ' PSID
<Out> ByRef pfEqual As Integer ' BOOL* out
) As Boolean
End Function' pSid1 : PSID
' pSid2 : PSID
' pfEqual : BOOL* out
Declare PtrSafe Function EqualDomainSid Lib "advapi32" ( _
ByVal pSid1 As LongPtr, _
ByVal pSid2 As LongPtr, _
ByRef pfEqual As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EqualDomainSid = ctypes.windll.advapi32.EqualDomainSid
EqualDomainSid.restype = wintypes.BOOL
EqualDomainSid.argtypes = [
wintypes.HANDLE, # pSid1 : PSID
wintypes.HANDLE, # pSid2 : PSID
ctypes.c_void_p, # pfEqual : BOOL* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
EqualDomainSid = Fiddle::Function.new(
lib['EqualDomainSid'],
[
Fiddle::TYPE_VOIDP, # pSid1 : PSID
Fiddle::TYPE_VOIDP, # pSid2 : PSID
Fiddle::TYPE_VOIDP, # pfEqual : BOOL* out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn EqualDomainSid(
pSid1: *mut core::ffi::c_void, // PSID
pSid2: *mut core::ffi::c_void, // PSID
pfEqual: *mut i32 // BOOL* out
) -> 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 EqualDomainSid(IntPtr pSid1, IntPtr pSid2, out int pfEqual);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_EqualDomainSid' -Namespace Win32 -PassThru
# $api::EqualDomainSid(pSid1, pSid2, pfEqual)#uselib "ADVAPI32.dll"
#func global EqualDomainSid "EqualDomainSid" sptr, sptr, sptr
; EqualDomainSid pSid1, pSid2, pfEqual ; 戻り値は stat
; pSid1 : PSID -> "sptr"
; pSid2 : PSID -> "sptr"
; pfEqual : BOOL* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global EqualDomainSid "EqualDomainSid" sptr, sptr, int
; res = EqualDomainSid(pSid1, pSid2, pfEqual)
; pSid1 : PSID -> "sptr"
; pSid2 : PSID -> "sptr"
; pfEqual : BOOL* out -> "int"; BOOL EqualDomainSid(PSID pSid1, PSID pSid2, BOOL* pfEqual)
#uselib "ADVAPI32.dll"
#cfunc global EqualDomainSid "EqualDomainSid" intptr, intptr, int
; res = EqualDomainSid(pSid1, pSid2, pfEqual)
; pSid1 : PSID -> "intptr"
; pSid2 : PSID -> "intptr"
; pfEqual : BOOL* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procEqualDomainSid = advapi32.NewProc("EqualDomainSid")
)
// pSid1 (PSID), pSid2 (PSID), pfEqual (BOOL* out)
r1, _, err := procEqualDomainSid.Call(
uintptr(pSid1),
uintptr(pSid2),
uintptr(pfEqual),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction EqualDomainSid(
pSid1: THandle; // PSID
pSid2: THandle; // PSID
pfEqual: Pointer // BOOL* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'EqualDomainSid';result := DllCall("ADVAPI32\EqualDomainSid"
, "Ptr", pSid1 ; PSID
, "Ptr", pSid2 ; PSID
, "Ptr", pfEqual ; BOOL* out
, "Int") ; return: BOOL●EqualDomainSid(pSid1, pSid2, pfEqual) = DLL("ADVAPI32.dll", "bool EqualDomainSid(void*, void*, void*)")
# 呼び出し: EqualDomainSid(pSid1, pSid2, pfEqual)
# pSid1 : PSID -> "void*"
# pSid2 : PSID -> "void*"
# pfEqual : BOOL* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。