ホーム › System.ApplicationInstallationAndServicing › TestApplyPatchToFileByHandles
TestApplyPatchToFileByHandles
関数ハンドル経由でパッチが適用可能かを検証する。
シグネチャ
// mspatcha.dll
#include <windows.h>
BOOL TestApplyPatchToFileByHandles(
HANDLE PatchFileHandle,
HANDLE OldFileHandle,
DWORD ApplyOptionFlags
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| PatchFileHandle | HANDLE | in |
| OldFileHandle | HANDLE | in |
| ApplyOptionFlags | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// mspatcha.dll
#include <windows.h>
BOOL TestApplyPatchToFileByHandles(
HANDLE PatchFileHandle,
HANDLE OldFileHandle,
DWORD ApplyOptionFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll", ExactSpelling = true)]
static extern bool TestApplyPatchToFileByHandles(
IntPtr PatchFileHandle, // HANDLE
IntPtr OldFileHandle, // HANDLE
uint ApplyOptionFlags // DWORD
);<DllImport("mspatcha.dll", ExactSpelling:=True)>
Public Shared Function TestApplyPatchToFileByHandles(
PatchFileHandle As IntPtr, ' HANDLE
OldFileHandle As IntPtr, ' HANDLE
ApplyOptionFlags As UInteger ' DWORD
) As Boolean
End Function' PatchFileHandle : HANDLE
' OldFileHandle : HANDLE
' ApplyOptionFlags : DWORD
Declare PtrSafe Function TestApplyPatchToFileByHandles Lib "mspatcha" ( _
ByVal PatchFileHandle As LongPtr, _
ByVal OldFileHandle As LongPtr, _
ByVal ApplyOptionFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
TestApplyPatchToFileByHandles = ctypes.windll.mspatcha.TestApplyPatchToFileByHandles
TestApplyPatchToFileByHandles.restype = wintypes.BOOL
TestApplyPatchToFileByHandles.argtypes = [
wintypes.HANDLE, # PatchFileHandle : HANDLE
wintypes.HANDLE, # OldFileHandle : HANDLE
wintypes.DWORD, # ApplyOptionFlags : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('mspatcha.dll')
TestApplyPatchToFileByHandles = Fiddle::Function.new(
lib['TestApplyPatchToFileByHandles'],
[
Fiddle::TYPE_VOIDP, # PatchFileHandle : HANDLE
Fiddle::TYPE_VOIDP, # OldFileHandle : HANDLE
-Fiddle::TYPE_INT, # ApplyOptionFlags : DWORD
],
Fiddle::TYPE_INT)#[link(name = "mspatcha")]
extern "system" {
fn TestApplyPatchToFileByHandles(
PatchFileHandle: *mut core::ffi::c_void, // HANDLE
OldFileHandle: *mut core::ffi::c_void, // HANDLE
ApplyOptionFlags: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll")]
public static extern bool TestApplyPatchToFileByHandles(IntPtr PatchFileHandle, IntPtr OldFileHandle, uint ApplyOptionFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mspatcha_TestApplyPatchToFileByHandles' -Namespace Win32 -PassThru
# $api::TestApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, ApplyOptionFlags)#uselib "mspatcha.dll"
#func global TestApplyPatchToFileByHandles "TestApplyPatchToFileByHandles" sptr, sptr, sptr
; TestApplyPatchToFileByHandles PatchFileHandle, OldFileHandle, ApplyOptionFlags ; 戻り値は stat
; PatchFileHandle : HANDLE -> "sptr"
; OldFileHandle : HANDLE -> "sptr"
; ApplyOptionFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "mspatcha.dll"
#cfunc global TestApplyPatchToFileByHandles "TestApplyPatchToFileByHandles" sptr, sptr, int
; res = TestApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, ApplyOptionFlags)
; PatchFileHandle : HANDLE -> "sptr"
; OldFileHandle : HANDLE -> "sptr"
; ApplyOptionFlags : DWORD -> "int"; BOOL TestApplyPatchToFileByHandles(HANDLE PatchFileHandle, HANDLE OldFileHandle, DWORD ApplyOptionFlags)
#uselib "mspatcha.dll"
#cfunc global TestApplyPatchToFileByHandles "TestApplyPatchToFileByHandles" intptr, intptr, int
; res = TestApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, ApplyOptionFlags)
; PatchFileHandle : HANDLE -> "intptr"
; OldFileHandle : HANDLE -> "intptr"
; ApplyOptionFlags : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mspatcha = windows.NewLazySystemDLL("mspatcha.dll")
procTestApplyPatchToFileByHandles = mspatcha.NewProc("TestApplyPatchToFileByHandles")
)
// PatchFileHandle (HANDLE), OldFileHandle (HANDLE), ApplyOptionFlags (DWORD)
r1, _, err := procTestApplyPatchToFileByHandles.Call(
uintptr(PatchFileHandle),
uintptr(OldFileHandle),
uintptr(ApplyOptionFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction TestApplyPatchToFileByHandles(
PatchFileHandle: THandle; // HANDLE
OldFileHandle: THandle; // HANDLE
ApplyOptionFlags: DWORD // DWORD
): BOOL; stdcall;
external 'mspatcha.dll' name 'TestApplyPatchToFileByHandles';result := DllCall("mspatcha\TestApplyPatchToFileByHandles"
, "Ptr", PatchFileHandle ; HANDLE
, "Ptr", OldFileHandle ; HANDLE
, "UInt", ApplyOptionFlags ; DWORD
, "Int") ; return: BOOL●TestApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, ApplyOptionFlags) = DLL("mspatcha.dll", "bool TestApplyPatchToFileByHandles(void*, void*, dword)")
# 呼び出し: TestApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, ApplyOptionFlags)
# PatchFileHandle : HANDLE -> "void*"
# OldFileHandle : HANDLE -> "void*"
# ApplyOptionFlags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。