Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › MsiRecordGetStringA

MsiRecordGetStringA

関数
レコードの指定フィールドから文字列値を取得する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiRecordGetStringA(
    MSIHANDLE hRecord,
    DWORD iField,
    LPSTR szValueBuf,   // optional
    DWORD* pcchValueBuf   // optional
);

パラメーター

名前方向
hRecordMSIHANDLEin
iFieldDWORDin
szValueBufLPSTRoutoptional
pcchValueBufDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiRecordGetStringA(
    MSIHANDLE hRecord,
    DWORD iField,
    LPSTR szValueBuf,   // optional
    DWORD* pcchValueBuf   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiRecordGetStringA(
    uint hRecord,   // MSIHANDLE
    uint iField,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szValueBuf,   // LPSTR optional, out
    IntPtr pcchValueBuf   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiRecordGetStringA(
    hRecord As UInteger,   ' MSIHANDLE
    iField As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> szValueBuf As System.Text.StringBuilder,   ' LPSTR optional, out
    pcchValueBuf As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' hRecord : MSIHANDLE
' iField : DWORD
' szValueBuf : LPSTR optional, out
' pcchValueBuf : DWORD* optional, in/out
Declare PtrSafe Function MsiRecordGetStringA Lib "msi" ( _
    ByVal hRecord As Long, _
    ByVal iField As Long, _
    ByVal szValueBuf As String, _
    ByVal pcchValueBuf As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiRecordGetStringA = ctypes.windll.msi.MsiRecordGetStringA
MsiRecordGetStringA.restype = wintypes.DWORD
MsiRecordGetStringA.argtypes = [
    wintypes.DWORD,  # hRecord : MSIHANDLE
    wintypes.DWORD,  # iField : DWORD
    wintypes.LPSTR,  # szValueBuf : LPSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchValueBuf : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiRecordGetStringA = Fiddle::Function.new(
  lib['MsiRecordGetStringA'],
  [
    -Fiddle::TYPE_INT,  # hRecord : MSIHANDLE
    -Fiddle::TYPE_INT,  # iField : DWORD
    Fiddle::TYPE_VOIDP,  # szValueBuf : LPSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchValueBuf : DWORD* optional, in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiRecordGetStringA(
        hRecord: u32,  // MSIHANDLE
        iField: u32,  // DWORD
        szValueBuf: *mut u8,  // LPSTR optional, out
        pcchValueBuf: *mut u32  // DWORD* optional, in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiRecordGetStringA(uint hRecord, uint iField, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szValueBuf, IntPtr pcchValueBuf);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiRecordGetStringA' -Namespace Win32 -PassThru
# $api::MsiRecordGetStringA(hRecord, iField, szValueBuf, pcchValueBuf)
#uselib "msi.dll"
#func global MsiRecordGetStringA "MsiRecordGetStringA" sptr, sptr, sptr, sptr
; MsiRecordGetStringA hRecord, iField, varptr(szValueBuf), varptr(pcchValueBuf)   ; 戻り値は stat
; hRecord : MSIHANDLE -> "sptr"
; iField : DWORD -> "sptr"
; szValueBuf : LPSTR optional, out -> "sptr"
; pcchValueBuf : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiRecordGetStringA "MsiRecordGetStringA" int, int, var, var
; res = MsiRecordGetStringA(hRecord, iField, szValueBuf, pcchValueBuf)
; hRecord : MSIHANDLE -> "int"
; iField : DWORD -> "int"
; szValueBuf : LPSTR optional, out -> "var"
; pcchValueBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiRecordGetStringA(MSIHANDLE hRecord, DWORD iField, LPSTR szValueBuf, DWORD* pcchValueBuf)
#uselib "msi.dll"
#cfunc global MsiRecordGetStringA "MsiRecordGetStringA" int, int, var, var
; res = MsiRecordGetStringA(hRecord, iField, szValueBuf, pcchValueBuf)
; hRecord : MSIHANDLE -> "int"
; iField : DWORD -> "int"
; szValueBuf : LPSTR optional, out -> "var"
; pcchValueBuf : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiRecordGetStringA = msi.NewProc("MsiRecordGetStringA")
)

// hRecord (MSIHANDLE), iField (DWORD), szValueBuf (LPSTR optional, out), pcchValueBuf (DWORD* optional, in/out)
r1, _, err := procMsiRecordGetStringA.Call(
	uintptr(hRecord),
	uintptr(iField),
	uintptr(szValueBuf),
	uintptr(pcchValueBuf),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiRecordGetStringA(
  hRecord: DWORD;   // MSIHANDLE
  iField: DWORD;   // DWORD
  szValueBuf: PAnsiChar;   // LPSTR optional, out
  pcchValueBuf: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiRecordGetStringA';
result := DllCall("msi\MsiRecordGetStringA"
    , "UInt", hRecord   ; MSIHANDLE
    , "UInt", iField   ; DWORD
    , "Ptr", szValueBuf   ; LPSTR optional, out
    , "Ptr", pcchValueBuf   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiRecordGetStringA(hRecord, iField, szValueBuf, pcchValueBuf) = DLL("msi.dll", "dword MsiRecordGetStringA(dword, dword, char*, void*)")
# 呼び出し: MsiRecordGetStringA(hRecord, iField, szValueBuf, pcchValueBuf)
# hRecord : MSIHANDLE -> "dword"
# iField : DWORD -> "dword"
# szValueBuf : LPSTR optional, out -> "char*"
# pcchValueBuf : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。