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

CreatePatchFileW

関数
旧ファイルと新ファイルの差分パッチファイルを作成する(Unicode版)。
DLLmspatchc.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// mspatchc.dll  (Unicode / -W)
#include <windows.h>

BOOL CreatePatchFileW(
    LPCWSTR OldFileName,   // optional
    LPCWSTR NewFileName,
    LPCWSTR PatchFileName,
    DWORD OptionFlags,
    PATCH_OPTION_DATA* OptionData   // optional
);

パラメーター

名前方向
OldFileNameLPCWSTRinoptional
NewFileNameLPCWSTRin
PatchFileNameLPCWSTRin
OptionFlagsDWORDin
OptionDataPATCH_OPTION_DATA*inoptional

戻り値の型: BOOL

各言語での呼び出し定義

// mspatchc.dll  (Unicode / -W)
#include <windows.h>

BOOL CreatePatchFileW(
    LPCWSTR OldFileName,   // optional
    LPCWSTR NewFileName,
    LPCWSTR PatchFileName,
    DWORD OptionFlags,
    PATCH_OPTION_DATA* OptionData   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatchc.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool CreatePatchFileW(
    [MarshalAs(UnmanagedType.LPWStr)] string OldFileName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string NewFileName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string PatchFileName,   // LPCWSTR
    uint OptionFlags,   // DWORD
    IntPtr OptionData   // PATCH_OPTION_DATA* optional
);
<DllImport("mspatchc.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CreatePatchFileW(
    <MarshalAs(UnmanagedType.LPWStr)> OldFileName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> NewFileName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> PatchFileName As String,   ' LPCWSTR
    OptionFlags As UInteger,   ' DWORD
    OptionData As IntPtr   ' PATCH_OPTION_DATA* optional
) As Boolean
End Function
' OldFileName : LPCWSTR optional
' NewFileName : LPCWSTR
' PatchFileName : LPCWSTR
' OptionFlags : DWORD
' OptionData : PATCH_OPTION_DATA* optional
Declare PtrSafe Function CreatePatchFileW Lib "mspatchc" ( _
    ByVal OldFileName As LongPtr, _
    ByVal NewFileName As LongPtr, _
    ByVal PatchFileName As LongPtr, _
    ByVal OptionFlags As Long, _
    ByVal OptionData As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreatePatchFileW = ctypes.windll.mspatchc.CreatePatchFileW
CreatePatchFileW.restype = wintypes.BOOL
CreatePatchFileW.argtypes = [
    wintypes.LPCWSTR,  # OldFileName : LPCWSTR optional
    wintypes.LPCWSTR,  # NewFileName : LPCWSTR
    wintypes.LPCWSTR,  # PatchFileName : LPCWSTR
    wintypes.DWORD,  # OptionFlags : DWORD
    ctypes.c_void_p,  # OptionData : PATCH_OPTION_DATA* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mspatchc.dll')
CreatePatchFileW = Fiddle::Function.new(
  lib['CreatePatchFileW'],
  [
    Fiddle::TYPE_VOIDP,  # OldFileName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # NewFileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # PatchFileName : LPCWSTR
    -Fiddle::TYPE_INT,  # OptionFlags : DWORD
    Fiddle::TYPE_VOIDP,  # OptionData : PATCH_OPTION_DATA* optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "mspatchc")]
extern "system" {
    fn CreatePatchFileW(
        OldFileName: *const u16,  // LPCWSTR optional
        NewFileName: *const u16,  // LPCWSTR
        PatchFileName: *const u16,  // LPCWSTR
        OptionFlags: u32,  // DWORD
        OptionData: *mut PATCH_OPTION_DATA  // PATCH_OPTION_DATA* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatchc.dll", CharSet = CharSet.Unicode)]
public static extern bool CreatePatchFileW([MarshalAs(UnmanagedType.LPWStr)] string OldFileName, [MarshalAs(UnmanagedType.LPWStr)] string NewFileName, [MarshalAs(UnmanagedType.LPWStr)] string PatchFileName, uint OptionFlags, IntPtr OptionData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mspatchc_CreatePatchFileW' -Namespace Win32 -PassThru
# $api::CreatePatchFileW(OldFileName, NewFileName, PatchFileName, OptionFlags, OptionData)
#uselib "mspatchc.dll"
#func global CreatePatchFileW "CreatePatchFileW" wptr, wptr, wptr, wptr, wptr
; CreatePatchFileW OldFileName, NewFileName, PatchFileName, OptionFlags, varptr(OptionData)   ; 戻り値は stat
; OldFileName : LPCWSTR optional -> "wptr"
; NewFileName : LPCWSTR -> "wptr"
; PatchFileName : LPCWSTR -> "wptr"
; OptionFlags : DWORD -> "wptr"
; OptionData : PATCH_OPTION_DATA* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "mspatchc.dll"
#cfunc global CreatePatchFileW "CreatePatchFileW" wstr, wstr, wstr, int, var
; res = CreatePatchFileW(OldFileName, NewFileName, PatchFileName, OptionFlags, OptionData)
; OldFileName : LPCWSTR optional -> "wstr"
; NewFileName : LPCWSTR -> "wstr"
; PatchFileName : LPCWSTR -> "wstr"
; OptionFlags : DWORD -> "int"
; OptionData : PATCH_OPTION_DATA* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL CreatePatchFileW(LPCWSTR OldFileName, LPCWSTR NewFileName, LPCWSTR PatchFileName, DWORD OptionFlags, PATCH_OPTION_DATA* OptionData)
#uselib "mspatchc.dll"
#cfunc global CreatePatchFileW "CreatePatchFileW" wstr, wstr, wstr, int, var
; res = CreatePatchFileW(OldFileName, NewFileName, PatchFileName, OptionFlags, OptionData)
; OldFileName : LPCWSTR optional -> "wstr"
; NewFileName : LPCWSTR -> "wstr"
; PatchFileName : LPCWSTR -> "wstr"
; OptionFlags : DWORD -> "int"
; OptionData : PATCH_OPTION_DATA* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mspatchc = windows.NewLazySystemDLL("mspatchc.dll")
	procCreatePatchFileW = mspatchc.NewProc("CreatePatchFileW")
)

// OldFileName (LPCWSTR optional), NewFileName (LPCWSTR), PatchFileName (LPCWSTR), OptionFlags (DWORD), OptionData (PATCH_OPTION_DATA* optional)
r1, _, err := procCreatePatchFileW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(OldFileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(NewFileName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(PatchFileName))),
	uintptr(OptionFlags),
	uintptr(OptionData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function CreatePatchFileW(
  OldFileName: PWideChar;   // LPCWSTR optional
  NewFileName: PWideChar;   // LPCWSTR
  PatchFileName: PWideChar;   // LPCWSTR
  OptionFlags: DWORD;   // DWORD
  OptionData: Pointer   // PATCH_OPTION_DATA* optional
): BOOL; stdcall;
  external 'mspatchc.dll' name 'CreatePatchFileW';
result := DllCall("mspatchc\CreatePatchFileW"
    , "WStr", OldFileName   ; LPCWSTR optional
    , "WStr", NewFileName   ; LPCWSTR
    , "WStr", PatchFileName   ; LPCWSTR
    , "UInt", OptionFlags   ; DWORD
    , "Ptr", OptionData   ; PATCH_OPTION_DATA* optional
    , "Int")   ; return: BOOL
●CreatePatchFileW(OldFileName, NewFileName, PatchFileName, OptionFlags, OptionData) = DLL("mspatchc.dll", "bool CreatePatchFileW(char*, char*, char*, dword, void*)")
# 呼び出し: CreatePatchFileW(OldFileName, NewFileName, PatchFileName, OptionFlags, OptionData)
# OldFileName : LPCWSTR optional -> "char*"
# NewFileName : LPCWSTR -> "char*"
# PatchFileName : LPCWSTR -> "char*"
# OptionFlags : DWORD -> "dword"
# OptionData : PATCH_OPTION_DATA* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。