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

TestApplyPatchToFileW

関数
パッチが旧ファイルに適用可能かを実適用せずに検証する(Unicode版)。
DLLmspatcha.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

BOOL TestApplyPatchToFileW(
    LPCWSTR PatchFileName,
    LPCWSTR OldFileName,
    DWORD ApplyOptionFlags
);

パラメーター

名前方向
PatchFileNameLPCWSTRin
OldFileNameLPCWSTRin
ApplyOptionFlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL TestApplyPatchToFileW(
    LPCWSTR PatchFileName,
    LPCWSTR OldFileName,
    DWORD ApplyOptionFlags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool TestApplyPatchToFileW(
    [MarshalAs(UnmanagedType.LPWStr)] string PatchFileName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string OldFileName,   // LPCWSTR
    uint ApplyOptionFlags   // DWORD
);
<DllImport("mspatcha.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function TestApplyPatchToFileW(
    <MarshalAs(UnmanagedType.LPWStr)> PatchFileName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> OldFileName As String,   ' LPCWSTR
    ApplyOptionFlags As UInteger   ' DWORD
) As Boolean
End Function
' PatchFileName : LPCWSTR
' OldFileName : LPCWSTR
' ApplyOptionFlags : DWORD
Declare PtrSafe Function TestApplyPatchToFileW Lib "mspatcha" ( _
    ByVal PatchFileName As LongPtr, _
    ByVal OldFileName As LongPtr, _
    ByVal ApplyOptionFlags As Long) 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

TestApplyPatchToFileW = ctypes.windll.mspatcha.TestApplyPatchToFileW
TestApplyPatchToFileW.restype = wintypes.BOOL
TestApplyPatchToFileW.argtypes = [
    wintypes.LPCWSTR,  # PatchFileName : LPCWSTR
    wintypes.LPCWSTR,  # OldFileName : LPCWSTR
    wintypes.DWORD,  # ApplyOptionFlags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('mspatcha.dll')
TestApplyPatchToFileW = Fiddle::Function.new(
  lib['TestApplyPatchToFileW'],
  [
    Fiddle::TYPE_VOIDP,  # PatchFileName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # OldFileName : LPCWSTR
    -Fiddle::TYPE_INT,  # ApplyOptionFlags : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "mspatcha")]
extern "system" {
    fn TestApplyPatchToFileW(
        PatchFileName: *const u16,  // LPCWSTR
        OldFileName: *const u16,  // LPCWSTR
        ApplyOptionFlags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mspatcha.dll", CharSet = CharSet.Unicode)]
public static extern bool TestApplyPatchToFileW([MarshalAs(UnmanagedType.LPWStr)] string PatchFileName, [MarshalAs(UnmanagedType.LPWStr)] string OldFileName, uint ApplyOptionFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'mspatcha_TestApplyPatchToFileW' -Namespace Win32 -PassThru
# $api::TestApplyPatchToFileW(PatchFileName, OldFileName, ApplyOptionFlags)
#uselib "mspatcha.dll"
#func global TestApplyPatchToFileW "TestApplyPatchToFileW" wptr, wptr, wptr
; TestApplyPatchToFileW PatchFileName, OldFileName, ApplyOptionFlags   ; 戻り値は stat
; PatchFileName : LPCWSTR -> "wptr"
; OldFileName : LPCWSTR -> "wptr"
; ApplyOptionFlags : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "mspatcha.dll"
#cfunc global TestApplyPatchToFileW "TestApplyPatchToFileW" wstr, wstr, int
; res = TestApplyPatchToFileW(PatchFileName, OldFileName, ApplyOptionFlags)
; PatchFileName : LPCWSTR -> "wstr"
; OldFileName : LPCWSTR -> "wstr"
; ApplyOptionFlags : DWORD -> "int"
; BOOL TestApplyPatchToFileW(LPCWSTR PatchFileName, LPCWSTR OldFileName, DWORD ApplyOptionFlags)
#uselib "mspatcha.dll"
#cfunc global TestApplyPatchToFileW "TestApplyPatchToFileW" wstr, wstr, int
; res = TestApplyPatchToFileW(PatchFileName, OldFileName, ApplyOptionFlags)
; PatchFileName : LPCWSTR -> "wstr"
; OldFileName : LPCWSTR -> "wstr"
; ApplyOptionFlags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mspatcha = windows.NewLazySystemDLL("mspatcha.dll")
	procTestApplyPatchToFileW = mspatcha.NewProc("TestApplyPatchToFileW")
)

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