ホーム › System.ApplicationInstallationAndServicing › ApplyDeltaW
ApplyDeltaW
関数ソースファイルにデルタを適用してターゲットファイルを生成する(Unicode版)。
シグネチャ
// msdelta.dll (Unicode / -W)
#include <windows.h>
BOOL ApplyDeltaW(
LONGLONG ApplyFlags,
LPCWSTR lpSourceName,
LPCWSTR lpDeltaName,
LPCWSTR lpTargetName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ApplyFlags | LONGLONG | in | デルタ適用動作を制御するフラグ。DELTA_APPLY_FLAG_* を指定する。 |
| lpSourceName | LPCWSTR | in | 適用元ソースファイルのパス。Unicode 文字列で指定する。 |
| lpDeltaName | LPCWSTR | in | 適用するデルタファイルのパス。Unicode 文字列で指定する。 |
| lpTargetName | LPCWSTR | in | 適用結果を書き込むターゲットファイルのパス。Unicode 文字列で指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// msdelta.dll (Unicode / -W)
#include <windows.h>
BOOL ApplyDeltaW(
LONGLONG ApplyFlags,
LPCWSTR lpSourceName,
LPCWSTR lpDeltaName,
LPCWSTR lpTargetName
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("msdelta.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool ApplyDeltaW(
long ApplyFlags, // LONGLONG
[MarshalAs(UnmanagedType.LPWStr)] string lpSourceName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpDeltaName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpTargetName // LPCWSTR
);<DllImport("msdelta.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function ApplyDeltaW(
ApplyFlags As Long, ' LONGLONG
<MarshalAs(UnmanagedType.LPWStr)> lpSourceName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpDeltaName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpTargetName As String ' LPCWSTR
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' ApplyFlags : LONGLONG
' lpSourceName : LPCWSTR
' lpDeltaName : LPCWSTR
' lpTargetName : LPCWSTR
Declare PtrSafe Function ApplyDeltaW Lib "msdelta" ( _
ByVal ApplyFlags As LongLong, _
ByVal lpSourceName As LongPtr, _
ByVal lpDeltaName As LongPtr, _
ByVal lpTargetName 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
ApplyDeltaW = ctypes.windll.msdelta.ApplyDeltaW
ApplyDeltaW.restype = wintypes.BOOL
ApplyDeltaW.argtypes = [
ctypes.c_longlong, # ApplyFlags : LONGLONG
wintypes.LPCWSTR, # lpSourceName : LPCWSTR
wintypes.LPCWSTR, # lpDeltaName : LPCWSTR
wintypes.LPCWSTR, # lpTargetName : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msdelta.dll')
ApplyDeltaW = Fiddle::Function.new(
lib['ApplyDeltaW'],
[
Fiddle::TYPE_LONG_LONG, # ApplyFlags : LONGLONG
Fiddle::TYPE_VOIDP, # lpSourceName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpDeltaName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpTargetName : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msdelta")]
extern "system" {
fn ApplyDeltaW(
ApplyFlags: i64, // LONGLONG
lpSourceName: *const u16, // LPCWSTR
lpDeltaName: *const u16, // LPCWSTR
lpTargetName: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("msdelta.dll", CharSet = CharSet.Unicode)]
public static extern bool ApplyDeltaW(long ApplyFlags, [MarshalAs(UnmanagedType.LPWStr)] string lpSourceName, [MarshalAs(UnmanagedType.LPWStr)] string lpDeltaName, [MarshalAs(UnmanagedType.LPWStr)] string lpTargetName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msdelta_ApplyDeltaW' -Namespace Win32 -PassThru
# $api::ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)#uselib "msdelta.dll"
#func global ApplyDeltaW "ApplyDeltaW" wptr, wptr, wptr, wptr
; ApplyDeltaW ApplyFlags, lpSourceName, lpDeltaName, lpTargetName ; 戻り値は stat
; ApplyFlags : LONGLONG -> "wptr"
; lpSourceName : LPCWSTR -> "wptr"
; lpDeltaName : LPCWSTR -> "wptr"
; lpTargetName : LPCWSTR -> "wptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msdelta.dll"
#cfunc global ApplyDeltaW "ApplyDeltaW" int64, wstr, wstr, wstr
; res = ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
; ApplyFlags : LONGLONG -> "int64"
; lpSourceName : LPCWSTR -> "wstr"
; lpDeltaName : LPCWSTR -> "wstr"
; lpTargetName : LPCWSTR -> "wstr"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; BOOL ApplyDeltaW(LONGLONG ApplyFlags, LPCWSTR lpSourceName, LPCWSTR lpDeltaName, LPCWSTR lpTargetName)
#uselib "msdelta.dll"
#cfunc global ApplyDeltaW "ApplyDeltaW" int64, wstr, wstr, wstr
; res = ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
; ApplyFlags : LONGLONG -> "int64"
; lpSourceName : LPCWSTR -> "wstr"
; lpDeltaName : LPCWSTR -> "wstr"
; lpTargetName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msdelta = windows.NewLazySystemDLL("msdelta.dll")
procApplyDeltaW = msdelta.NewProc("ApplyDeltaW")
)
// ApplyFlags (LONGLONG), lpSourceName (LPCWSTR), lpDeltaName (LPCWSTR), lpTargetName (LPCWSTR)
r1, _, err := procApplyDeltaW.Call(
uintptr(ApplyFlags),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpSourceName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpDeltaName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpTargetName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ApplyDeltaW(
ApplyFlags: Int64; // LONGLONG
lpSourceName: PWideChar; // LPCWSTR
lpDeltaName: PWideChar; // LPCWSTR
lpTargetName: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'msdelta.dll' name 'ApplyDeltaW';result := DllCall("msdelta\ApplyDeltaW"
, "Int64", ApplyFlags ; LONGLONG
, "WStr", lpSourceName ; LPCWSTR
, "WStr", lpDeltaName ; LPCWSTR
, "WStr", lpTargetName ; LPCWSTR
, "Int") ; return: BOOL●ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName) = DLL("msdelta.dll", "bool ApplyDeltaW(int64, char*, char*, char*)")
# 呼び出し: ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
# ApplyFlags : LONGLONG -> "int64"
# lpSourceName : LPCWSTR -> "char*"
# lpDeltaName : LPCWSTR -> "char*"
# lpTargetName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "msdelta" fn ApplyDeltaW(
ApplyFlags: i64, // LONGLONG
lpSourceName: [*c]const u16, // LPCWSTR
lpDeltaName: [*c]const u16, // LPCWSTR
lpTargetName: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc ApplyDeltaW(
ApplyFlags: int64, # LONGLONG
lpSourceName: WideCString, # LPCWSTR
lpDeltaName: WideCString, # LPCWSTR
lpTargetName: WideCString # LPCWSTR
): int32 {.importc: "ApplyDeltaW", stdcall, dynlib: "msdelta.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "msdelta");
extern(Windows)
int ApplyDeltaW(
long ApplyFlags, // LONGLONG
const(wchar)* lpSourceName, // LPCWSTR
const(wchar)* lpDeltaName, // LPCWSTR
const(wchar)* lpTargetName // LPCWSTR
);ccall((:ApplyDeltaW, "msdelta.dll"), stdcall, Int32,
(Int64, Cwstring, Cwstring, Cwstring),
ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
# ApplyFlags : LONGLONG -> Int64
# lpSourceName : LPCWSTR -> Cwstring
# lpDeltaName : LPCWSTR -> Cwstring
# lpTargetName : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t ApplyDeltaW(
int64_t ApplyFlags,
const uint16_t* lpSourceName,
const uint16_t* lpDeltaName,
const uint16_t* lpTargetName);
]]
local msdelta = ffi.load("msdelta")
-- msdelta.ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
-- ApplyFlags : LONGLONG
-- lpSourceName : LPCWSTR
-- lpDeltaName : LPCWSTR
-- lpTargetName : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('msdelta.dll');
const ApplyDeltaW = lib.func('__stdcall', 'ApplyDeltaW', 'int32_t', ['int64_t', 'str16', 'str16', 'str16']);
// ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
// ApplyFlags : LONGLONG -> 'int64_t'
// lpSourceName : LPCWSTR -> 'str16'
// lpDeltaName : LPCWSTR -> 'str16'
// lpTargetName : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msdelta.dll", {
ApplyDeltaW: { parameters: ["i64", "buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName)
// ApplyFlags : LONGLONG -> "i64"
// lpSourceName : LPCWSTR -> "buffer"
// lpDeltaName : LPCWSTR -> "buffer"
// lpTargetName : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ApplyDeltaW(
int64_t ApplyFlags,
const uint16_t* lpSourceName,
const uint16_t* lpDeltaName,
const uint16_t* lpTargetName);
C, "msdelta.dll");
// $ffi->ApplyDeltaW(ApplyFlags, lpSourceName, lpDeltaName, lpTargetName);
// ApplyFlags : LONGLONG
// lpSourceName : LPCWSTR
// lpDeltaName : LPCWSTR
// lpTargetName : LPCWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Msdelta extends StdCallLibrary {
Msdelta INSTANCE = Native.load("msdelta", Msdelta.class, W32APIOptions.UNICODE_OPTIONS);
boolean ApplyDeltaW(
long ApplyFlags, // LONGLONG
WString lpSourceName, // LPCWSTR
WString lpDeltaName, // LPCWSTR
WString lpTargetName // LPCWSTR
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("msdelta")]
lib Libmsdelta
fun ApplyDeltaW = ApplyDeltaW(
ApplyFlags : Int64, # LONGLONG
lpSourceName : UInt16*, # LPCWSTR
lpDeltaName : UInt16*, # LPCWSTR
lpTargetName : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ApplyDeltaWNative = Int32 Function(Int64, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
typedef ApplyDeltaWDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>);
final ApplyDeltaW = DynamicLibrary.open('msdelta.dll')
.lookupFunction<ApplyDeltaWNative, ApplyDeltaWDart>('ApplyDeltaW');
// ApplyFlags : LONGLONG -> Int64
// lpSourceName : LPCWSTR -> Pointer<Utf16>
// lpDeltaName : LPCWSTR -> Pointer<Utf16>
// lpTargetName : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ApplyDeltaW(
ApplyFlags: Int64; // LONGLONG
lpSourceName: PWideChar; // LPCWSTR
lpDeltaName: PWideChar; // LPCWSTR
lpTargetName: PWideChar // LPCWSTR
): BOOL; stdcall;
external 'msdelta.dll' name 'ApplyDeltaW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ApplyDeltaW"
c_ApplyDeltaW :: Int64 -> CWString -> CWString -> CWString -> IO CInt
-- ApplyFlags : LONGLONG -> Int64
-- lpSourceName : LPCWSTR -> CWString
-- lpDeltaName : LPCWSTR -> CWString
-- lpTargetName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let applydeltaw =
foreign "ApplyDeltaW"
(int64_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* ApplyFlags : LONGLONG -> int64_t *)
(* lpSourceName : LPCWSTR -> (ptr uint16_t) *)
(* lpDeltaName : LPCWSTR -> (ptr uint16_t) *)
(* lpTargetName : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msdelta (t "msdelta.dll"))
(cffi:use-foreign-library msdelta)
(cffi:defcfun ("ApplyDeltaW" apply-delta-w :convention :stdcall) :int32
(apply-flags :int64) ; LONGLONG
(lp-source-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-delta-name (:string :encoding :utf-16le)) ; LPCWSTR
(lp-target-name (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ApplyDeltaW = Win32::API::More->new('msdelta',
'BOOL ApplyDeltaW(INT64 ApplyFlags, LPCWSTR lpSourceName, LPCWSTR lpDeltaName, LPCWSTR lpTargetName)');
# my $ret = $ApplyDeltaW->Call($ApplyFlags, $lpSourceName, $lpDeltaName, $lpTargetName);
# ApplyFlags : LONGLONG -> INT64
# lpSourceName : LPCWSTR -> LPCWSTR
# lpDeltaName : LPCWSTR -> LPCWSTR
# lpTargetName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f ApplyDeltaA (ANSI版) — ソースファイルにデルタを適用してターゲットファイルを生成する(ANSI版)。