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