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

NCryptGetProtectionDescriptorInfo

関数
保護記述子ハンドルから情報を取得する。
DLLncrypt.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT NCryptGetProtectionDescriptorInfo(
    NCRYPT_DESCRIPTOR_HANDLE hDescriptor,
    const NCRYPT_ALLOC_PARA* pMemPara,   // optional
    DWORD dwInfoType,
    void** ppvInfo
);

パラメーター

名前方向
hDescriptorNCRYPT_DESCRIPTOR_HANDLEin
pMemParaNCRYPT_ALLOC_PARA*inoptional
dwInfoTypeDWORDin
ppvInfovoid**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT NCryptGetProtectionDescriptorInfo(
    NCRYPT_DESCRIPTOR_HANDLE hDescriptor,
    const NCRYPT_ALLOC_PARA* pMemPara,   // optional
    DWORD dwInfoType,
    void** ppvInfo
);
[DllImport("ncrypt.dll", ExactSpelling = true)]
static extern int NCryptGetProtectionDescriptorInfo(
    IntPtr hDescriptor,   // NCRYPT_DESCRIPTOR_HANDLE
    IntPtr pMemPara,   // NCRYPT_ALLOC_PARA* optional
    uint dwInfoType,   // DWORD
    IntPtr ppvInfo   // void** out
);
<DllImport("ncrypt.dll", ExactSpelling:=True)>
Public Shared Function NCryptGetProtectionDescriptorInfo(
    hDescriptor As IntPtr,   ' NCRYPT_DESCRIPTOR_HANDLE
    pMemPara As IntPtr,   ' NCRYPT_ALLOC_PARA* optional
    dwInfoType As UInteger,   ' DWORD
    ppvInfo As IntPtr   ' void** out
) As Integer
End Function
' hDescriptor : NCRYPT_DESCRIPTOR_HANDLE
' pMemPara : NCRYPT_ALLOC_PARA* optional
' dwInfoType : DWORD
' ppvInfo : void** out
Declare PtrSafe Function NCryptGetProtectionDescriptorInfo Lib "ncrypt" ( _
    ByVal hDescriptor As LongPtr, _
    ByVal pMemPara As LongPtr, _
    ByVal dwInfoType As Long, _
    ByVal ppvInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NCryptGetProtectionDescriptorInfo = ctypes.windll.ncrypt.NCryptGetProtectionDescriptorInfo
NCryptGetProtectionDescriptorInfo.restype = ctypes.c_int
NCryptGetProtectionDescriptorInfo.argtypes = [
    wintypes.HANDLE,  # hDescriptor : NCRYPT_DESCRIPTOR_HANDLE
    ctypes.c_void_p,  # pMemPara : NCRYPT_ALLOC_PARA* optional
    wintypes.DWORD,  # dwInfoType : DWORD
    ctypes.c_void_p,  # ppvInfo : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ncrypt.dll')
NCryptGetProtectionDescriptorInfo = Fiddle::Function.new(
  lib['NCryptGetProtectionDescriptorInfo'],
  [
    Fiddle::TYPE_VOIDP,  # hDescriptor : NCRYPT_DESCRIPTOR_HANDLE
    Fiddle::TYPE_VOIDP,  # pMemPara : NCRYPT_ALLOC_PARA* optional
    -Fiddle::TYPE_INT,  # dwInfoType : DWORD
    Fiddle::TYPE_VOIDP,  # ppvInfo : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "ncrypt")]
extern "system" {
    fn NCryptGetProtectionDescriptorInfo(
        hDescriptor: *mut core::ffi::c_void,  // NCRYPT_DESCRIPTOR_HANDLE
        pMemPara: *const NCRYPT_ALLOC_PARA,  // NCRYPT_ALLOC_PARA* optional
        dwInfoType: u32,  // DWORD
        ppvInfo: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("ncrypt.dll")]
public static extern int NCryptGetProtectionDescriptorInfo(IntPtr hDescriptor, IntPtr pMemPara, uint dwInfoType, IntPtr ppvInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ncrypt_NCryptGetProtectionDescriptorInfo' -Namespace Win32 -PassThru
# $api::NCryptGetProtectionDescriptorInfo(hDescriptor, pMemPara, dwInfoType, ppvInfo)
#uselib "ncrypt.dll"
#func global NCryptGetProtectionDescriptorInfo "NCryptGetProtectionDescriptorInfo" sptr, sptr, sptr, sptr
; NCryptGetProtectionDescriptorInfo hDescriptor, varptr(pMemPara), dwInfoType, ppvInfo   ; 戻り値は stat
; hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> "sptr"
; pMemPara : NCRYPT_ALLOC_PARA* optional -> "sptr"
; dwInfoType : DWORD -> "sptr"
; ppvInfo : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "ncrypt.dll"
#cfunc global NCryptGetProtectionDescriptorInfo "NCryptGetProtectionDescriptorInfo" sptr, var, int, sptr
; res = NCryptGetProtectionDescriptorInfo(hDescriptor, pMemPara, dwInfoType, ppvInfo)
; hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> "sptr"
; pMemPara : NCRYPT_ALLOC_PARA* optional -> "var"
; dwInfoType : DWORD -> "int"
; ppvInfo : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT NCryptGetProtectionDescriptorInfo(NCRYPT_DESCRIPTOR_HANDLE hDescriptor, NCRYPT_ALLOC_PARA* pMemPara, DWORD dwInfoType, void** ppvInfo)
#uselib "ncrypt.dll"
#cfunc global NCryptGetProtectionDescriptorInfo "NCryptGetProtectionDescriptorInfo" intptr, var, int, intptr
; res = NCryptGetProtectionDescriptorInfo(hDescriptor, pMemPara, dwInfoType, ppvInfo)
; hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> "intptr"
; pMemPara : NCRYPT_ALLOC_PARA* optional -> "var"
; dwInfoType : DWORD -> "int"
; ppvInfo : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ncrypt = windows.NewLazySystemDLL("ncrypt.dll")
	procNCryptGetProtectionDescriptorInfo = ncrypt.NewProc("NCryptGetProtectionDescriptorInfo")
)

// hDescriptor (NCRYPT_DESCRIPTOR_HANDLE), pMemPara (NCRYPT_ALLOC_PARA* optional), dwInfoType (DWORD), ppvInfo (void** out)
r1, _, err := procNCryptGetProtectionDescriptorInfo.Call(
	uintptr(hDescriptor),
	uintptr(pMemPara),
	uintptr(dwInfoType),
	uintptr(ppvInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function NCryptGetProtectionDescriptorInfo(
  hDescriptor: THandle;   // NCRYPT_DESCRIPTOR_HANDLE
  pMemPara: Pointer;   // NCRYPT_ALLOC_PARA* optional
  dwInfoType: DWORD;   // DWORD
  ppvInfo: Pointer   // void** out
): Integer; stdcall;
  external 'ncrypt.dll' name 'NCryptGetProtectionDescriptorInfo';
result := DllCall("ncrypt\NCryptGetProtectionDescriptorInfo"
    , "Ptr", hDescriptor   ; NCRYPT_DESCRIPTOR_HANDLE
    , "Ptr", pMemPara   ; NCRYPT_ALLOC_PARA* optional
    , "UInt", dwInfoType   ; DWORD
    , "Ptr", ppvInfo   ; void** out
    , "Int")   ; return: HRESULT
●NCryptGetProtectionDescriptorInfo(hDescriptor, pMemPara, dwInfoType, ppvInfo) = DLL("ncrypt.dll", "int NCryptGetProtectionDescriptorInfo(void*, void*, dword, void*)")
# 呼び出し: NCryptGetProtectionDescriptorInfo(hDescriptor, pMemPara, dwInfoType, ppvInfo)
# hDescriptor : NCRYPT_DESCRIPTOR_HANDLE -> "void*"
# pMemPara : NCRYPT_ALLOC_PARA* optional -> "void*"
# dwInfoType : DWORD -> "dword"
# ppvInfo : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。