Win32 API 日本語リファレンス
ホームSystem.Diagnostics.Debug › ImageRemoveCertificate

ImageRemoveCertificate

関数
イメージファイルから指定した証明書を削除する。
DLLimagehlp.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL ImageRemoveCertificate(
    HANDLE FileHandle,
    DWORD Index
);

パラメーター

名前方向
FileHandleHANDLEin
IndexDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ImageRemoveCertificate(
    HANDLE FileHandle,
    DWORD Index
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("imagehlp.dll", SetLastError = true, ExactSpelling = true)]
static extern bool ImageRemoveCertificate(
    IntPtr FileHandle,   // HANDLE
    uint Index   // DWORD
);
<DllImport("imagehlp.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ImageRemoveCertificate(
    FileHandle As IntPtr,   ' HANDLE
    Index As UInteger   ' DWORD
) As Boolean
End Function
' FileHandle : HANDLE
' Index : DWORD
Declare PtrSafe Function ImageRemoveCertificate Lib "imagehlp" ( _
    ByVal FileHandle As LongPtr, _
    ByVal Index As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ImageRemoveCertificate = ctypes.windll.imagehlp.ImageRemoveCertificate
ImageRemoveCertificate.restype = wintypes.BOOL
ImageRemoveCertificate.argtypes = [
    wintypes.HANDLE,  # FileHandle : HANDLE
    wintypes.DWORD,  # Index : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	imagehlp = windows.NewLazySystemDLL("imagehlp.dll")
	procImageRemoveCertificate = imagehlp.NewProc("ImageRemoveCertificate")
)

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