Win32 API 日本語リファレンス
ホームStorage.CloudFilters › CfGetWin32HandleFromProtectedHandle

CfGetWin32HandleFromProtectedHandle

関数
保護されたハンドルから通常のWin32ハンドルを取得する。
DLLcldapi.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HANDLE CfGetWin32HandleFromProtectedHandle(
    HANDLE ProtectedHandle
);

パラメーター

名前方向
ProtectedHandleHANDLEin

戻り値の型: HANDLE

各言語での呼び出し定義

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

HANDLE CfGetWin32HandleFromProtectedHandle(
    HANDLE ProtectedHandle
);
[DllImport("cldapi.dll", ExactSpelling = true)]
static extern IntPtr CfGetWin32HandleFromProtectedHandle(
    IntPtr ProtectedHandle   // HANDLE
);
<DllImport("cldapi.dll", ExactSpelling:=True)>
Public Shared Function CfGetWin32HandleFromProtectedHandle(
    ProtectedHandle As IntPtr   ' HANDLE
) As IntPtr
End Function
' ProtectedHandle : HANDLE
Declare PtrSafe Function CfGetWin32HandleFromProtectedHandle Lib "cldapi" ( _
    ByVal ProtectedHandle As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CfGetWin32HandleFromProtectedHandle = ctypes.windll.cldapi.CfGetWin32HandleFromProtectedHandle
CfGetWin32HandleFromProtectedHandle.restype = ctypes.c_void_p
CfGetWin32HandleFromProtectedHandle.argtypes = [
    wintypes.HANDLE,  # ProtectedHandle : HANDLE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	cldapi = windows.NewLazySystemDLL("cldapi.dll")
	procCfGetWin32HandleFromProtectedHandle = cldapi.NewProc("CfGetWin32HandleFromProtectedHandle")
)

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