ホーム › System.ApplicationInstallationAndServicing › MsiRecordSetStringW
MsiRecordSetStringW
関数レコードの指定フィールドに文字列値を設定する。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiRecordSetStringW(
MSIHANDLE hRecord,
DWORD iField,
LPCWSTR szValue
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hRecord | MSIHANDLE | in |
| iField | DWORD | in |
| szValue | LPCWSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiRecordSetStringW(
MSIHANDLE hRecord,
DWORD iField,
LPCWSTR szValue
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiRecordSetStringW(
uint hRecord, // MSIHANDLE
uint iField, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string szValue // LPCWSTR
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiRecordSetStringW(
hRecord As UInteger, ' MSIHANDLE
iField As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> szValue As String ' LPCWSTR
) As UInteger
End Function' hRecord : MSIHANDLE
' iField : DWORD
' szValue : LPCWSTR
Declare PtrSafe Function MsiRecordSetStringW Lib "msi" ( _
ByVal hRecord As Long, _
ByVal iField As Long, _
ByVal szValue 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
MsiRecordSetStringW = ctypes.windll.msi.MsiRecordSetStringW
MsiRecordSetStringW.restype = wintypes.DWORD
MsiRecordSetStringW.argtypes = [
wintypes.DWORD, # hRecord : MSIHANDLE
wintypes.DWORD, # iField : DWORD
wintypes.LPCWSTR, # szValue : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiRecordSetStringW = Fiddle::Function.new(
lib['MsiRecordSetStringW'],
[
-Fiddle::TYPE_INT, # hRecord : MSIHANDLE
-Fiddle::TYPE_INT, # iField : DWORD
Fiddle::TYPE_VOIDP, # szValue : LPCWSTR
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiRecordSetStringW(
hRecord: u32, // MSIHANDLE
iField: u32, // DWORD
szValue: *const u16 // LPCWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiRecordSetStringW(uint hRecord, uint iField, [MarshalAs(UnmanagedType.LPWStr)] string szValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiRecordSetStringW' -Namespace Win32 -PassThru
# $api::MsiRecordSetStringW(hRecord, iField, szValue)#uselib "msi.dll"
#func global MsiRecordSetStringW "MsiRecordSetStringW" wptr, wptr, wptr
; MsiRecordSetStringW hRecord, iField, szValue ; 戻り値は stat
; hRecord : MSIHANDLE -> "wptr"
; iField : DWORD -> "wptr"
; szValue : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiRecordSetStringW "MsiRecordSetStringW" int, int, wstr
; res = MsiRecordSetStringW(hRecord, iField, szValue)
; hRecord : MSIHANDLE -> "int"
; iField : DWORD -> "int"
; szValue : LPCWSTR -> "wstr"; DWORD MsiRecordSetStringW(MSIHANDLE hRecord, DWORD iField, LPCWSTR szValue)
#uselib "msi.dll"
#cfunc global MsiRecordSetStringW "MsiRecordSetStringW" int, int, wstr
; res = MsiRecordSetStringW(hRecord, iField, szValue)
; hRecord : MSIHANDLE -> "int"
; iField : DWORD -> "int"
; szValue : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiRecordSetStringW = msi.NewProc("MsiRecordSetStringW")
)
// hRecord (MSIHANDLE), iField (DWORD), szValue (LPCWSTR)
r1, _, err := procMsiRecordSetStringW.Call(
uintptr(hRecord),
uintptr(iField),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szValue))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiRecordSetStringW(
hRecord: DWORD; // MSIHANDLE
iField: DWORD; // DWORD
szValue: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'msi.dll' name 'MsiRecordSetStringW';result := DllCall("msi\MsiRecordSetStringW"
, "UInt", hRecord ; MSIHANDLE
, "UInt", iField ; DWORD
, "WStr", szValue ; LPCWSTR
, "UInt") ; return: DWORD●MsiRecordSetStringW(hRecord, iField, szValue) = DLL("msi.dll", "dword MsiRecordSetStringW(dword, dword, char*)")
# 呼び出し: MsiRecordSetStringW(hRecord, iField, szValue)
# hRecord : MSIHANDLE -> "dword"
# iField : DWORD -> "dword"
# szValue : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。