Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › ApplyPatchToFileByHandles

ApplyPatchToFileByHandles

関数
ハンドル経由で旧ファイルにパッチを適用して新ファイルを生成する。
DLLmspatcha.dll呼出規約winapi

シグネチャ

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

BOOL ApplyPatchToFileByHandles(
    HANDLE PatchFileHandle,
    HANDLE OldFileHandle,   // optional
    HANDLE NewFileHandle,
    DWORD ApplyOptionFlags
);

パラメーター

名前方向
PatchFileHandleHANDLEin
OldFileHandleHANDLEinoptional
NewFileHandleHANDLEin
ApplyOptionFlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ApplyPatchToFileByHandles(
    HANDLE PatchFileHandle,
    HANDLE OldFileHandle,   // optional
    HANDLE NewFileHandle,
    DWORD ApplyOptionFlags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll", ExactSpelling = true)]
static extern bool ApplyPatchToFileByHandles(
    IntPtr PatchFileHandle,   // HANDLE
    IntPtr OldFileHandle,   // HANDLE optional
    IntPtr NewFileHandle,   // HANDLE
    uint ApplyOptionFlags   // DWORD
);
<DllImport("mspatcha.dll", ExactSpelling:=True)>
Public Shared Function ApplyPatchToFileByHandles(
    PatchFileHandle As IntPtr,   ' HANDLE
    OldFileHandle As IntPtr,   ' HANDLE optional
    NewFileHandle As IntPtr,   ' HANDLE
    ApplyOptionFlags As UInteger   ' DWORD
) As Boolean
End Function
' PatchFileHandle : HANDLE
' OldFileHandle : HANDLE optional
' NewFileHandle : HANDLE
' ApplyOptionFlags : DWORD
Declare PtrSafe Function ApplyPatchToFileByHandles Lib "mspatcha" ( _
    ByVal PatchFileHandle As LongPtr, _
    ByVal OldFileHandle As LongPtr, _
    ByVal NewFileHandle 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

ApplyPatchToFileByHandles = ctypes.windll.mspatcha.ApplyPatchToFileByHandles
ApplyPatchToFileByHandles.restype = wintypes.BOOL
ApplyPatchToFileByHandles.argtypes = [
    wintypes.HANDLE,  # PatchFileHandle : HANDLE
    wintypes.HANDLE,  # OldFileHandle : HANDLE optional
    wintypes.HANDLE,  # NewFileHandle : HANDLE
    wintypes.DWORD,  # ApplyOptionFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mspatcha.dll')
ApplyPatchToFileByHandles = Fiddle::Function.new(
  lib['ApplyPatchToFileByHandles'],
  [
    Fiddle::TYPE_VOIDP,  # PatchFileHandle : HANDLE
    Fiddle::TYPE_VOIDP,  # OldFileHandle : HANDLE optional
    Fiddle::TYPE_VOIDP,  # NewFileHandle : HANDLE
    -Fiddle::TYPE_INT,  # ApplyOptionFlags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "mspatcha")]
extern "system" {
    fn ApplyPatchToFileByHandles(
        PatchFileHandle: *mut core::ffi::c_void,  // HANDLE
        OldFileHandle: *mut core::ffi::c_void,  // HANDLE optional
        NewFileHandle: *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 ApplyPatchToFileByHandles(IntPtr PatchFileHandle, IntPtr OldFileHandle, IntPtr NewFileHandle, uint ApplyOptionFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mspatcha_ApplyPatchToFileByHandles' -Namespace Win32 -PassThru
# $api::ApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, NewFileHandle, ApplyOptionFlags)
#uselib "mspatcha.dll"
#func global ApplyPatchToFileByHandles "ApplyPatchToFileByHandles" sptr, sptr, sptr, sptr
; ApplyPatchToFileByHandles PatchFileHandle, OldFileHandle, NewFileHandle, ApplyOptionFlags   ; 戻り値は stat
; PatchFileHandle : HANDLE -> "sptr"
; OldFileHandle : HANDLE optional -> "sptr"
; NewFileHandle : HANDLE -> "sptr"
; ApplyOptionFlags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mspatcha.dll"
#cfunc global ApplyPatchToFileByHandles "ApplyPatchToFileByHandles" sptr, sptr, sptr, int
; res = ApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, NewFileHandle, ApplyOptionFlags)
; PatchFileHandle : HANDLE -> "sptr"
; OldFileHandle : HANDLE optional -> "sptr"
; NewFileHandle : HANDLE -> "sptr"
; ApplyOptionFlags : DWORD -> "int"
; BOOL ApplyPatchToFileByHandles(HANDLE PatchFileHandle, HANDLE OldFileHandle, HANDLE NewFileHandle, DWORD ApplyOptionFlags)
#uselib "mspatcha.dll"
#cfunc global ApplyPatchToFileByHandles "ApplyPatchToFileByHandles" intptr, intptr, intptr, int
; res = ApplyPatchToFileByHandles(PatchFileHandle, OldFileHandle, NewFileHandle, ApplyOptionFlags)
; PatchFileHandle : HANDLE -> "intptr"
; OldFileHandle : HANDLE optional -> "intptr"
; NewFileHandle : HANDLE -> "intptr"
; ApplyOptionFlags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mspatcha = windows.NewLazySystemDLL("mspatcha.dll")
	procApplyPatchToFileByHandles = mspatcha.NewProc("ApplyPatchToFileByHandles")
)

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