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