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

CfReleaseProtectedHandle

関数
保護されたハンドルの参照を解放する。
DLLcldapi.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

void CfReleaseProtectedHandle(
    HANDLE ProtectedHandle
);

パラメーター

名前方向説明
ProtectedHandleHANDLEin解放する保護付きハンドル。参照カウントを減らし不要になれば閉じる。

戻り値の型: void

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('cldapi.dll')
CfReleaseProtectedHandle = Fiddle::Function.new(
  lib['CfReleaseProtectedHandle'],
  [
    Fiddle::TYPE_VOIDP,  # ProtectedHandle : HANDLE
  ],
  Fiddle::TYPE_VOID)
#[link(name = "cldapi")]
extern "system" {
    fn CfReleaseProtectedHandle(
        ProtectedHandle: *mut core::ffi::c_void  // HANDLE
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("cldapi.dll")]
public static extern void CfReleaseProtectedHandle(IntPtr ProtectedHandle);
"@
$api = Add-Type -MemberDefinition $sig -Name 'cldapi_CfReleaseProtectedHandle' -Namespace Win32 -PassThru
# $api::CfReleaseProtectedHandle(ProtectedHandle)
#uselib "cldapi.dll"
#func global CfReleaseProtectedHandle "CfReleaseProtectedHandle" sptr
; CfReleaseProtectedHandle ProtectedHandle
; ProtectedHandle : HANDLE -> "sptr"
#uselib "cldapi.dll"
#func global CfReleaseProtectedHandle "CfReleaseProtectedHandle" sptr
; CfReleaseProtectedHandle ProtectedHandle
; ProtectedHandle : HANDLE -> "sptr"
; void CfReleaseProtectedHandle(HANDLE ProtectedHandle)
#uselib "cldapi.dll"
#func global CfReleaseProtectedHandle "CfReleaseProtectedHandle" intptr
; CfReleaseProtectedHandle ProtectedHandle
; ProtectedHandle : HANDLE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cldapi = windows.NewLazySystemDLL("cldapi.dll")
	procCfReleaseProtectedHandle = cldapi.NewProc("CfReleaseProtectedHandle")
)

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

extern "cldapi" fn CfReleaseProtectedHandle(
    ProtectedHandle: ?*anyopaque // HANDLE
) callconv(std.os.windows.WINAPI) void;
proc CfReleaseProtectedHandle(
    ProtectedHandle: pointer  # HANDLE
) {.importc: "CfReleaseProtectedHandle", stdcall, dynlib: "cldapi.dll".}
pragma(lib, "cldapi");
extern(Windows)
void CfReleaseProtectedHandle(
    void* ProtectedHandle   // HANDLE
);
ccall((:CfReleaseProtectedHandle, "cldapi.dll"), stdcall, Cvoid,
      (Ptr{Cvoid},),
      ProtectedHandle)
# ProtectedHandle : HANDLE -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void CfReleaseProtectedHandle(
    void* ProtectedHandle);
]]
local cldapi = ffi.load("cldapi")
-- cldapi.CfReleaseProtectedHandle(ProtectedHandle)
-- ProtectedHandle : HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('cldapi.dll');
const CfReleaseProtectedHandle = lib.func('__stdcall', 'CfReleaseProtectedHandle', 'void', ['void *']);
// CfReleaseProtectedHandle(ProtectedHandle)
// ProtectedHandle : HANDLE -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("cldapi.dll", {
  CfReleaseProtectedHandle: { parameters: ["pointer"], result: "void" },
});
// lib.symbols.CfReleaseProtectedHandle(ProtectedHandle)
// ProtectedHandle : HANDLE -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void CfReleaseProtectedHandle(
    void* ProtectedHandle);
C, "cldapi.dll");
// $ffi->CfReleaseProtectedHandle(ProtectedHandle);
// ProtectedHandle : HANDLE
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Cldapi extends StdCallLibrary {
    Cldapi INSTANCE = Native.load("cldapi", Cldapi.class);
    void CfReleaseProtectedHandle(
        Pointer ProtectedHandle   // HANDLE
    );
}
@[Link("cldapi")]
lib Libcldapi
  fun CfReleaseProtectedHandle = CfReleaseProtectedHandle(
    ProtectedHandle : Void*   # HANDLE
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CfReleaseProtectedHandleNative = Void Function(Pointer<Void>);
typedef CfReleaseProtectedHandleDart = void Function(Pointer<Void>);
final CfReleaseProtectedHandle = DynamicLibrary.open('cldapi.dll')
    .lookupFunction<CfReleaseProtectedHandleNative, CfReleaseProtectedHandleDart>('CfReleaseProtectedHandle');
// ProtectedHandle : HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure CfReleaseProtectedHandle(
  ProtectedHandle: THandle   // HANDLE
); stdcall;
  external 'cldapi.dll' name 'CfReleaseProtectedHandle';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CfReleaseProtectedHandle"
  c_CfReleaseProtectedHandle :: Ptr () -> IO ()
-- ProtectedHandle : HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let cfreleaseprotectedhandle =
  foreign "CfReleaseProtectedHandle"
    ((ptr void) @-> returning void)
(* ProtectedHandle : HANDLE -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library cldapi (t "cldapi.dll"))
(cffi:use-foreign-library cldapi)

(cffi:defcfun ("CfReleaseProtectedHandle" cf-release-protected-handle :convention :stdcall) :void
  (protected-handle :pointer))   ; HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CfReleaseProtectedHandle = Win32::API::More->new('cldapi',
    'void CfReleaseProtectedHandle(HANDLE ProtectedHandle)');
# my $ret = $CfReleaseProtectedHandle->Call($ProtectedHandle);
# ProtectedHandle : HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。