ホーム › System.LibraryLoader › BeginUpdateResourceW
BeginUpdateResourceW
関数実行ファイルのリソース更新をUnicode名で開始する。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
HANDLE BeginUpdateResourceW(
LPCWSTR pFileName,
BOOL bDeleteExistingResources
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pFileName | LPCWSTR | in |
| bDeleteExistingResources | BOOL | in |
戻り値の型: HANDLE
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
HANDLE BeginUpdateResourceW(
LPCWSTR pFileName,
BOOL bDeleteExistingResources
);[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr BeginUpdateResourceW(
[MarshalAs(UnmanagedType.LPWStr)] string pFileName, // LPCWSTR
bool bDeleteExistingResources // BOOL
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BeginUpdateResourceW(
<MarshalAs(UnmanagedType.LPWStr)> pFileName As String, ' LPCWSTR
bDeleteExistingResources As Boolean ' BOOL
) As IntPtr
End Function' pFileName : LPCWSTR
' bDeleteExistingResources : BOOL
Declare PtrSafe Function BeginUpdateResourceW Lib "kernel32" ( _
ByVal pFileName As LongPtr, _
ByVal bDeleteExistingResources As Long) As LongPtr
' 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
BeginUpdateResourceW = ctypes.windll.kernel32.BeginUpdateResourceW
BeginUpdateResourceW.restype = ctypes.c_void_p
BeginUpdateResourceW.argtypes = [
wintypes.LPCWSTR, # pFileName : LPCWSTR
wintypes.BOOL, # bDeleteExistingResources : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
BeginUpdateResourceW = Fiddle::Function.new(
lib['BeginUpdateResourceW'],
[
Fiddle::TYPE_VOIDP, # pFileName : LPCWSTR
Fiddle::TYPE_INT, # bDeleteExistingResources : BOOL
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn BeginUpdateResourceW(
pFileName: *const u16, // LPCWSTR
bDeleteExistingResources: i32 // BOOL
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr BeginUpdateResourceW([MarshalAs(UnmanagedType.LPWStr)] string pFileName, bool bDeleteExistingResources);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_BeginUpdateResourceW' -Namespace Win32 -PassThru
# $api::BeginUpdateResourceW(pFileName, bDeleteExistingResources)#uselib "KERNEL32.dll"
#func global BeginUpdateResourceW "BeginUpdateResourceW" wptr, wptr
; BeginUpdateResourceW pFileName, bDeleteExistingResources ; 戻り値は stat
; pFileName : LPCWSTR -> "wptr"
; bDeleteExistingResources : BOOL -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global BeginUpdateResourceW "BeginUpdateResourceW" wstr, int
; res = BeginUpdateResourceW(pFileName, bDeleteExistingResources)
; pFileName : LPCWSTR -> "wstr"
; bDeleteExistingResources : BOOL -> "int"; HANDLE BeginUpdateResourceW(LPCWSTR pFileName, BOOL bDeleteExistingResources)
#uselib "KERNEL32.dll"
#cfunc global BeginUpdateResourceW "BeginUpdateResourceW" wstr, int
; res = BeginUpdateResourceW(pFileName, bDeleteExistingResources)
; pFileName : LPCWSTR -> "wstr"
; bDeleteExistingResources : BOOL -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procBeginUpdateResourceW = kernel32.NewProc("BeginUpdateResourceW")
)
// pFileName (LPCWSTR), bDeleteExistingResources (BOOL)
r1, _, err := procBeginUpdateResourceW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pFileName))),
uintptr(bDeleteExistingResources),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction BeginUpdateResourceW(
pFileName: PWideChar; // LPCWSTR
bDeleteExistingResources: BOOL // BOOL
): THandle; stdcall;
external 'KERNEL32.dll' name 'BeginUpdateResourceW';result := DllCall("KERNEL32\BeginUpdateResourceW"
, "WStr", pFileName ; LPCWSTR
, "Int", bDeleteExistingResources ; BOOL
, "Ptr") ; return: HANDLE●BeginUpdateResourceW(pFileName, bDeleteExistingResources) = DLL("KERNEL32.dll", "void* BeginUpdateResourceW(char*, bool)")
# 呼び出し: BeginUpdateResourceW(pFileName, bDeleteExistingResources)
# pFileName : LPCWSTR -> "char*"
# bDeleteExistingResources : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。