ホーム › System.LibraryLoader › UpdateResourceA
UpdateResourceA
関数実行ファイル内のリソースをANSI指定で更新する。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL UpdateResourceA(
HANDLE hUpdate,
LPCSTR lpType,
LPCSTR lpName,
WORD wLanguage,
void* lpData, // optional
DWORD cb
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hUpdate | HANDLE | in |
| lpType | LPCSTR | in |
| lpName | LPCSTR | in |
| wLanguage | WORD | in |
| lpData | void* | inoptional |
| cb | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL UpdateResourceA(
HANDLE hUpdate,
LPCSTR lpType,
LPCSTR lpName,
WORD wLanguage,
void* lpData, // optional
DWORD cb
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool UpdateResourceA(
IntPtr hUpdate, // HANDLE
[MarshalAs(UnmanagedType.LPStr)] string lpType, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string lpName, // LPCSTR
ushort wLanguage, // WORD
IntPtr lpData, // void* optional
uint cb // DWORD
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function UpdateResourceA(
hUpdate As IntPtr, ' HANDLE
<MarshalAs(UnmanagedType.LPStr)> lpType As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> lpName As String, ' LPCSTR
wLanguage As UShort, ' WORD
lpData As IntPtr, ' void* optional
cb As UInteger ' DWORD
) As Boolean
End Function' hUpdate : HANDLE
' lpType : LPCSTR
' lpName : LPCSTR
' wLanguage : WORD
' lpData : void* optional
' cb : DWORD
Declare PtrSafe Function UpdateResourceA Lib "kernel32" ( _
ByVal hUpdate As LongPtr, _
ByVal lpType As String, _
ByVal lpName As String, _
ByVal wLanguage As Integer, _
ByVal lpData As LongPtr, _
ByVal cb As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UpdateResourceA = ctypes.windll.kernel32.UpdateResourceA
UpdateResourceA.restype = wintypes.BOOL
UpdateResourceA.argtypes = [
wintypes.HANDLE, # hUpdate : HANDLE
wintypes.LPCSTR, # lpType : LPCSTR
wintypes.LPCSTR, # lpName : LPCSTR
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')
UpdateResourceA = Fiddle::Function.new(
lib['UpdateResourceA'],
[
Fiddle::TYPE_VOIDP, # hUpdate : HANDLE
Fiddle::TYPE_VOIDP, # lpType : LPCSTR
Fiddle::TYPE_VOIDP, # lpName : LPCSTR
-Fiddle::TYPE_SHORT, # wLanguage : WORD
Fiddle::TYPE_VOIDP, # lpData : void* optional
-Fiddle::TYPE_INT, # cb : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn UpdateResourceA(
hUpdate: *mut core::ffi::c_void, // HANDLE
lpType: *const u8, // LPCSTR
lpName: *const u8, // LPCSTR
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.Ansi, SetLastError = true)]
public static extern bool UpdateResourceA(IntPtr hUpdate, [MarshalAs(UnmanagedType.LPStr)] string lpType, [MarshalAs(UnmanagedType.LPStr)] string lpName, ushort wLanguage, IntPtr lpData, uint cb);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_UpdateResourceA' -Namespace Win32 -PassThru
# $api::UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb)#uselib "KERNEL32.dll"
#func global UpdateResourceA "UpdateResourceA" sptr, sptr, sptr, sptr, sptr, sptr
; UpdateResourceA hUpdate, lpType, lpName, wLanguage, lpData, cb ; 戻り値は stat
; hUpdate : HANDLE -> "sptr"
; lpType : LPCSTR -> "sptr"
; lpName : LPCSTR -> "sptr"
; wLanguage : WORD -> "sptr"
; lpData : void* optional -> "sptr"
; cb : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global UpdateResourceA "UpdateResourceA" sptr, str, str, int, sptr, int
; res = UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb)
; hUpdate : HANDLE -> "sptr"
; lpType : LPCSTR -> "str"
; lpName : LPCSTR -> "str"
; wLanguage : WORD -> "int"
; lpData : void* optional -> "sptr"
; cb : DWORD -> "int"; BOOL UpdateResourceA(HANDLE hUpdate, LPCSTR lpType, LPCSTR lpName, WORD wLanguage, void* lpData, DWORD cb)
#uselib "KERNEL32.dll"
#cfunc global UpdateResourceA "UpdateResourceA" intptr, str, str, int, intptr, int
; res = UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb)
; hUpdate : HANDLE -> "intptr"
; lpType : LPCSTR -> "str"
; lpName : LPCSTR -> "str"
; wLanguage : WORD -> "int"
; lpData : void* optional -> "intptr"
; cb : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procUpdateResourceA = kernel32.NewProc("UpdateResourceA")
)
// hUpdate (HANDLE), lpType (LPCSTR), lpName (LPCSTR), wLanguage (WORD), lpData (void* optional), cb (DWORD)
r1, _, err := procUpdateResourceA.Call(
uintptr(hUpdate),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpType))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpName))),
uintptr(wLanguage),
uintptr(lpData),
uintptr(cb),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction UpdateResourceA(
hUpdate: THandle; // HANDLE
lpType: PAnsiChar; // LPCSTR
lpName: PAnsiChar; // LPCSTR
wLanguage: Word; // WORD
lpData: Pointer; // void* optional
cb: DWORD // DWORD
): BOOL; stdcall;
external 'KERNEL32.dll' name 'UpdateResourceA';result := DllCall("KERNEL32\UpdateResourceA"
, "Ptr", hUpdate ; HANDLE
, "AStr", lpType ; LPCSTR
, "AStr", lpName ; LPCSTR
, "UShort", wLanguage ; WORD
, "Ptr", lpData ; void* optional
, "UInt", cb ; DWORD
, "Int") ; return: BOOL●UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb) = DLL("KERNEL32.dll", "bool UpdateResourceA(void*, char*, char*, int, void*, dword)")
# 呼び出し: UpdateResourceA(hUpdate, lpType, lpName, wLanguage, lpData, cb)
# hUpdate : HANDLE -> "void*"
# lpType : LPCSTR -> "char*"
# lpName : LPCSTR -> "char*"
# wLanguage : WORD -> "int"
# lpData : void* optional -> "void*"
# cb : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。