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

MsiFormatRecordA

関数
レコード内のフィールドとプロパティを書式化して文字列を生成する(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiFormatRecordA(
    MSIHANDLE hInstall,
    MSIHANDLE hRecord,
    LPSTR szResultBuf,   // optional
    DWORD* pcchResultBuf   // optional
);

パラメーター

名前方向
hInstallMSIHANDLEin
hRecordMSIHANDLEin
szResultBufLPSTRoutoptional
pcchResultBufDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MsiFormatRecordA = ctypes.windll.msi.MsiFormatRecordA
MsiFormatRecordA.restype = wintypes.DWORD
MsiFormatRecordA.argtypes = [
    wintypes.DWORD,  # hInstall : MSIHANDLE
    wintypes.DWORD,  # hRecord : MSIHANDLE
    wintypes.LPSTR,  # szResultBuf : LPSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchResultBuf : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiFormatRecordA = msi.NewProc("MsiFormatRecordA")
)

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