MsiSourceListGetInfoA
関数シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiSourceListGetInfoA(
LPCSTR szProductCodeOrPatchCode,
LPCSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
DWORD dwOptions,
LPCSTR szProperty,
LPSTR szValue, // optional
DWORD* pcchValue // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| szProductCodeOrPatchCode | LPCSTR | in | 製品またはパッチの ProductCode またはパッチ GUID。null 終端文字列を使用します。文字列が 39 文字を超える場合、関数は失敗し、ERROR_INVALID_PARAMETER を返します。このパラメーターを NULL にすることはできません。 | ||||||||||||
| szUserSid | LPCSTR | inoptional | このパラメーターには、製品またはパッチを保持するユーザーアカウントを指定する文字列形式のセキュリティ識別子 (SID) を指定できます。SID は検証も解決もされません。誤った SID を指定すると ERROR_UNKNOWN_PRODUCT または ERROR_UNKNOWN_PATCH が返される場合があります。マシンコンテキストを参照する場合、szUserSID は NULL でなければならず、dwContext は MSIINSTALLCONTEXT_MACHINE でなければなりません。
注意 特殊な SID 文字列 s-1-5-18 (system) は、 per-machine としてインストールされた製品またはパッチの列挙には使用できません。SID 値を s-1-5-18 に設定すると ERROR_INVALID_PARAMETER が返されます。
注意 特殊な SID 文字列 s-1-1-0 (everyone) は使用しないでください。SID 値を s-1-1-0 に設定すると失敗し、ERROR_INVALID_PARAM が返されます。
| ||||||||||||
| dwContext | MSIINSTALLCONTEXT | in | このパラメーターは、製品またはパッチのインスタンスのコンテキストを指定します。このパラメーターには次のいずれかの値を指定できます。
| ||||||||||||
| dwOptions | DWORD | in | dwOptions 値は szProductCodeOrPatchCode の意味を指定します。
| ||||||||||||
| szProperty | LPCSTR | in | 取得するプロパティ値を指定する null 終端文字列。szProperty パラメーターには次のいずれかの値を指定できます。
| ||||||||||||
| szValue | LPSTR | outoptional | 情報を受け取る出力バッファー。このバッファーは情報を格納できる十分な大きさである必要があります。バッファーが小さすぎる場合、関数は ERROR_MORE_DATA を返し、*pcchValue に値の TCHAR 数 (終端の NULL 文字を含まない) を設定します。 szValue を NULL に設定し、pcchValue を有効なポインターに設定した場合、関数は ERROR_SUCCESS を返し、pcchValue に値の TCHAR 数 (終端の NULL 文字を含まない) を設定します。その後、pcchValue + 1 文字を格納できる十分な大きさの szValue バッファーを指定して関数を再度呼び出し、値を取得できます。 szValue と pcchValue の両方を NULL に設定した場合、関数は値を取得せずに、値が存在すれば ERROR_SUCCESS を返します。 | ||||||||||||
| pcchValue | DWORD* | inoutoptional | szValue バッファー内の TCHAR 数を指定する変数へのポインター。関数が返るとき、このパラメーターには、関数が値を指定されたバッファーにコピーしたかどうかに関わらず、要求された値のサイズが設定されます。サイズは、要求された値の TCHAR 数 (終端の null 文字を含まない) として返されます。 このパラメーターを NULL に設定できるのは szValue も NULL の場合のみです。それ以外の場合、関数は ERROR_INVALID_PARAMETER を返します。 |
戻り値の型: DWORD
公式ドキュメント
MsiSourceListGetInfo 関数は、特定のコンテキストにおける製品またはパッチのソースリストに関する情報を取得します。(ANSI)
戻り値
MsiSourceListGetInfo 関数は次の値を返します。
| 値 | 意味 |
|---|---|
| ユーザーに指定されたソースリストを読み取る権限がありません。これは製品またはパッチが見つかったかどうかを示すものではありません。 | |
| 構成データが破損しています。 | |
| 無効なパラメーターが関数に渡されました。 | |
| 指定されたバッファーが要求されたデータを格納するのに十分ではありません。 | |
| プロパティが正常に取得されました。 | |
| パッチが見つかりません。 | |
| 製品が見つかりません。 | |
| ソースプロパティが見つかりません。 | |
| 予期しない内部エラーが発生しました。 |
解説(Remarks)
管理者は、マシンコンテキスト、または自身の per-user コンテキスト (managed または unmanaged) に存在する製品またはパッチのインスタンスのインストールを変更できます。また、任意のユーザーの per-user-managed コンテキストに存在する製品またはパッチのインスタンスのインストールを変更できます。管理者は、他のユーザーの per-user-unmanaged コンテキストに存在する、そのユーザーの製品またはパッチのインスタンスのインストールを変更することはできません。
管理者以外のユーザーは、他のユーザーの per-user コンテキスト (managed または unmanaged) に存在する製品またはパッチのインスタンスのインストールを変更できません。自身の per-user-unmanaged コンテキストに存在する製品またはパッチのインスタンスのインストールは変更できます。マシンコンテキストまたは自身の per-user-managed コンテキストに存在する製品またはパッチのインスタンスのインストールは、製品またはパッチのソースを参照することが許可されている場合にのみ変更できます。ユーザーがソースを参照できるようにするには、ポリシーを設定します。詳細については、DisableBrowse、AllowLockdownBrowse、AlwaysInstallElevated の各ポリシーを参照してください。
msi.h ヘッダーは、MsiSourceListGetInfo を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング中立のエイリアスの使用と、エンコーディング中立でないコードを混在させると、不一致が生じ、コンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
DWORD MsiSourceListGetInfoA(
LPCSTR szProductCodeOrPatchCode,
LPCSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
DWORD dwOptions,
LPCSTR szProperty,
LPSTR szValue, // optional
DWORD* pcchValue // optional
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiSourceListGetInfoA(
[MarshalAs(UnmanagedType.LPStr)] string szProductCodeOrPatchCode, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szUserSid, // LPCSTR optional
int dwContext, // MSIINSTALLCONTEXT
uint dwOptions, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string szProperty, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szValue, // LPSTR optional, out
IntPtr pcchValue // DWORD* optional, in/out
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiSourceListGetInfoA(
<MarshalAs(UnmanagedType.LPStr)> szProductCodeOrPatchCode As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szUserSid As String, ' LPCSTR optional
dwContext As Integer, ' MSIINSTALLCONTEXT
dwOptions As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> szProperty As String, ' LPCSTR
<MarshalAs(UnmanagedType.LPStr)> szValue As System.Text.StringBuilder, ' LPSTR optional, out
pcchValue As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' szProductCodeOrPatchCode : LPCSTR
' szUserSid : LPCSTR optional
' dwContext : MSIINSTALLCONTEXT
' dwOptions : DWORD
' szProperty : LPCSTR
' szValue : LPSTR optional, out
' pcchValue : DWORD* optional, in/out
Declare PtrSafe Function MsiSourceListGetInfoA Lib "msi" ( _
ByVal szProductCodeOrPatchCode As String, _
ByVal szUserSid As String, _
ByVal dwContext As Long, _
ByVal dwOptions As Long, _
ByVal szProperty As String, _
ByVal szValue As String, _
ByVal pcchValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiSourceListGetInfoA = ctypes.windll.msi.MsiSourceListGetInfoA
MsiSourceListGetInfoA.restype = wintypes.DWORD
MsiSourceListGetInfoA.argtypes = [
wintypes.LPCSTR, # szProductCodeOrPatchCode : LPCSTR
wintypes.LPCSTR, # szUserSid : LPCSTR optional
ctypes.c_int, # dwContext : MSIINSTALLCONTEXT
wintypes.DWORD, # dwOptions : DWORD
wintypes.LPCSTR, # szProperty : LPCSTR
wintypes.LPSTR, # szValue : LPSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pcchValue : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiSourceListGetInfoA = Fiddle::Function.new(
lib['MsiSourceListGetInfoA'],
[
Fiddle::TYPE_VOIDP, # szProductCodeOrPatchCode : LPCSTR
Fiddle::TYPE_VOIDP, # szUserSid : LPCSTR optional
Fiddle::TYPE_INT, # dwContext : MSIINSTALLCONTEXT
-Fiddle::TYPE_INT, # dwOptions : DWORD
Fiddle::TYPE_VOIDP, # szProperty : LPCSTR
Fiddle::TYPE_VOIDP, # szValue : LPSTR optional, out
Fiddle::TYPE_VOIDP, # pcchValue : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiSourceListGetInfoA(
szProductCodeOrPatchCode: *const u8, // LPCSTR
szUserSid: *const u8, // LPCSTR optional
dwContext: i32, // MSIINSTALLCONTEXT
dwOptions: u32, // DWORD
szProperty: *const u8, // LPCSTR
szValue: *mut u8, // LPSTR optional, out
pcchValue: *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 MsiSourceListGetInfoA([MarshalAs(UnmanagedType.LPStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPStr)] string szUserSid, int dwContext, uint dwOptions, [MarshalAs(UnmanagedType.LPStr)] string szProperty, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szValue, IntPtr pcchValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListGetInfoA' -Namespace Win32 -PassThru
# $api::MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue)#uselib "msi.dll"
#func global MsiSourceListGetInfoA "MsiSourceListGetInfoA" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; MsiSourceListGetInfoA szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, varptr(szValue), varptr(pcchValue) ; 戻り値は stat
; szProductCodeOrPatchCode : LPCSTR -> "sptr"
; szUserSid : LPCSTR optional -> "sptr"
; dwContext : MSIINSTALLCONTEXT -> "sptr"
; dwOptions : DWORD -> "sptr"
; szProperty : LPCSTR -> "sptr"
; szValue : LPSTR optional, out -> "sptr"
; pcchValue : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll" #cfunc global MsiSourceListGetInfoA "MsiSourceListGetInfoA" str, str, int, int, str, var, var ; res = MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue) ; szProductCodeOrPatchCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; dwOptions : DWORD -> "int" ; szProperty : LPCSTR -> "str" ; szValue : LPSTR optional, out -> "var" ; pcchValue : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiSourceListGetInfoA "MsiSourceListGetInfoA" str, str, int, int, str, sptr, sptr ; res = MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, varptr(szValue), varptr(pcchValue)) ; szProductCodeOrPatchCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; dwOptions : DWORD -> "int" ; szProperty : LPCSTR -> "str" ; szValue : LPSTR optional, out -> "sptr" ; pcchValue : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; DWORD MsiSourceListGetInfoA(LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szProperty, LPSTR szValue, DWORD* pcchValue) #uselib "msi.dll" #cfunc global MsiSourceListGetInfoA "MsiSourceListGetInfoA" str, str, int, int, str, var, var ; res = MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue) ; szProductCodeOrPatchCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; dwOptions : DWORD -> "int" ; szProperty : LPCSTR -> "str" ; szValue : LPSTR optional, out -> "var" ; pcchValue : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiSourceListGetInfoA(LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szProperty, LPSTR szValue, DWORD* pcchValue) #uselib "msi.dll" #cfunc global MsiSourceListGetInfoA "MsiSourceListGetInfoA" str, str, int, int, str, intptr, intptr ; res = MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, varptr(szValue), varptr(pcchValue)) ; szProductCodeOrPatchCode : LPCSTR -> "str" ; szUserSid : LPCSTR optional -> "str" ; dwContext : MSIINSTALLCONTEXT -> "int" ; dwOptions : DWORD -> "int" ; szProperty : LPCSTR -> "str" ; szValue : LPSTR optional, out -> "intptr" ; pcchValue : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiSourceListGetInfoA = msi.NewProc("MsiSourceListGetInfoA")
)
// szProductCodeOrPatchCode (LPCSTR), szUserSid (LPCSTR optional), dwContext (MSIINSTALLCONTEXT), dwOptions (DWORD), szProperty (LPCSTR), szValue (LPSTR optional, out), pcchValue (DWORD* optional, in/out)
r1, _, err := procMsiSourceListGetInfoA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProductCodeOrPatchCode))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szUserSid))),
uintptr(dwContext),
uintptr(dwOptions),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProperty))),
uintptr(szValue),
uintptr(pcchValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiSourceListGetInfoA(
szProductCodeOrPatchCode: PAnsiChar; // LPCSTR
szUserSid: PAnsiChar; // LPCSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT
dwOptions: DWORD; // DWORD
szProperty: PAnsiChar; // LPCSTR
szValue: PAnsiChar; // LPSTR optional, out
pcchValue: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiSourceListGetInfoA';result := DllCall("msi\MsiSourceListGetInfoA"
, "AStr", szProductCodeOrPatchCode ; LPCSTR
, "AStr", szUserSid ; LPCSTR optional
, "Int", dwContext ; MSIINSTALLCONTEXT
, "UInt", dwOptions ; DWORD
, "AStr", szProperty ; LPCSTR
, "Ptr", szValue ; LPSTR optional, out
, "Ptr", pcchValue ; DWORD* optional, in/out
, "UInt") ; return: DWORD●MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue) = DLL("msi.dll", "dword MsiSourceListGetInfoA(char*, char*, int, dword, char*, char*, void*)")
# 呼び出し: MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue)
# szProductCodeOrPatchCode : LPCSTR -> "char*"
# szUserSid : LPCSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# dwOptions : DWORD -> "dword"
# szProperty : LPCSTR -> "char*"
# szValue : LPSTR optional, out -> "char*"
# pcchValue : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "msi" fn MsiSourceListGetInfoA(
szProductCodeOrPatchCode: [*c]const u8, // LPCSTR
szUserSid: [*c]const u8, // LPCSTR optional
dwContext: i32, // MSIINSTALLCONTEXT
dwOptions: u32, // DWORD
szProperty: [*c]const u8, // LPCSTR
szValue: [*c]u8, // LPSTR optional, out
pcchValue: [*c]u32 // DWORD* optional, in/out
) callconv(std.os.windows.WINAPI) u32;proc MsiSourceListGetInfoA(
szProductCodeOrPatchCode: cstring, # LPCSTR
szUserSid: cstring, # LPCSTR optional
dwContext: int32, # MSIINSTALLCONTEXT
dwOptions: uint32, # DWORD
szProperty: cstring, # LPCSTR
szValue: ptr char, # LPSTR optional, out
pcchValue: ptr uint32 # DWORD* optional, in/out
): uint32 {.importc: "MsiSourceListGetInfoA", stdcall, dynlib: "msi.dll".}pragma(lib, "msi");
extern(Windows)
uint MsiSourceListGetInfoA(
const(char)* szProductCodeOrPatchCode, // LPCSTR
const(char)* szUserSid, // LPCSTR optional
int dwContext, // MSIINSTALLCONTEXT
uint dwOptions, // DWORD
const(char)* szProperty, // LPCSTR
char* szValue, // LPSTR optional, out
uint* pcchValue // DWORD* optional, in/out
);ccall((:MsiSourceListGetInfoA, "msi.dll"), stdcall, UInt32,
(Cstring, Cstring, Int32, UInt32, Cstring, Ptr{UInt8}, Ptr{UInt32}),
szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue)
# szProductCodeOrPatchCode : LPCSTR -> Cstring
# szUserSid : LPCSTR optional -> Cstring
# dwContext : MSIINSTALLCONTEXT -> Int32
# dwOptions : DWORD -> UInt32
# szProperty : LPCSTR -> Cstring
# szValue : LPSTR optional, out -> Ptr{UInt8}
# pcchValue : DWORD* optional, in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiSourceListGetInfoA(
const char* szProductCodeOrPatchCode,
const char* szUserSid,
int32_t dwContext,
uint32_t dwOptions,
const char* szProperty,
char* szValue,
uint32_t* pcchValue);
]]
local msi = ffi.load("msi")
-- msi.MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue)
-- szProductCodeOrPatchCode : LPCSTR
-- szUserSid : LPCSTR optional
-- dwContext : MSIINSTALLCONTEXT
-- dwOptions : DWORD
-- szProperty : LPCSTR
-- szValue : LPSTR optional, out
-- pcchValue : DWORD* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiSourceListGetInfoA = lib.func('__stdcall', 'MsiSourceListGetInfoA', 'uint32_t', ['str', 'str', 'int32_t', 'uint32_t', 'str', 'char *', 'uint32_t *']);
// MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue)
// szProductCodeOrPatchCode : LPCSTR -> 'str'
// szUserSid : LPCSTR optional -> 'str'
// dwContext : MSIINSTALLCONTEXT -> 'int32_t'
// dwOptions : DWORD -> 'uint32_t'
// szProperty : LPCSTR -> 'str'
// szValue : LPSTR optional, out -> 'char *'
// pcchValue : DWORD* optional, in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiSourceListGetInfoA: { parameters: ["buffer", "buffer", "i32", "u32", "buffer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue)
// szProductCodeOrPatchCode : LPCSTR -> "buffer"
// szUserSid : LPCSTR optional -> "buffer"
// dwContext : MSIINSTALLCONTEXT -> "i32"
// dwOptions : DWORD -> "u32"
// szProperty : LPCSTR -> "buffer"
// szValue : LPSTR optional, out -> "buffer"
// pcchValue : DWORD* optional, in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiSourceListGetInfoA(
const char* szProductCodeOrPatchCode,
const char* szUserSid,
int32_t dwContext,
uint32_t dwOptions,
const char* szProperty,
char* szValue,
uint32_t* pcchValue);
C, "msi.dll");
// $ffi->MsiSourceListGetInfoA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szProperty, szValue, pcchValue);
// szProductCodeOrPatchCode : LPCSTR
// szUserSid : LPCSTR optional
// dwContext : MSIINSTALLCONTEXT
// dwOptions : DWORD
// szProperty : LPCSTR
// szValue : LPSTR optional, out
// pcchValue : DWORD* optional, in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Msi extends StdCallLibrary {
Msi INSTANCE = Native.load("msi", Msi.class, W32APIOptions.ASCII_OPTIONS);
int MsiSourceListGetInfoA(
String szProductCodeOrPatchCode, // LPCSTR
String szUserSid, // LPCSTR optional
int dwContext, // MSIINSTALLCONTEXT
int dwOptions, // DWORD
String szProperty, // LPCSTR
byte[] szValue, // LPSTR optional, out
IntByReference pcchValue // DWORD* optional, in/out
);
}@[Link("msi")]
lib Libmsi
fun MsiSourceListGetInfoA = MsiSourceListGetInfoA(
szProductCodeOrPatchCode : UInt8*, # LPCSTR
szUserSid : UInt8*, # LPCSTR optional
dwContext : Int32, # MSIINSTALLCONTEXT
dwOptions : UInt32, # DWORD
szProperty : UInt8*, # LPCSTR
szValue : UInt8*, # LPSTR optional, out
pcchValue : UInt32* # DWORD* optional, in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiSourceListGetInfoANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Int32, Uint32, Pointer<Utf8>, Pointer<Utf8>, Pointer<Uint32>);
typedef MsiSourceListGetInfoADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int, int, Pointer<Utf8>, Pointer<Utf8>, Pointer<Uint32>);
final MsiSourceListGetInfoA = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiSourceListGetInfoANative, MsiSourceListGetInfoADart>('MsiSourceListGetInfoA');
// szProductCodeOrPatchCode : LPCSTR -> Pointer<Utf8>
// szUserSid : LPCSTR optional -> Pointer<Utf8>
// dwContext : MSIINSTALLCONTEXT -> Int32
// dwOptions : DWORD -> Uint32
// szProperty : LPCSTR -> Pointer<Utf8>
// szValue : LPSTR optional, out -> Pointer<Utf8>
// pcchValue : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiSourceListGetInfoA(
szProductCodeOrPatchCode: PAnsiChar; // LPCSTR
szUserSid: PAnsiChar; // LPCSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT
dwOptions: DWORD; // DWORD
szProperty: PAnsiChar; // LPCSTR
szValue: PAnsiChar; // LPSTR optional, out
pcchValue: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'msi.dll' name 'MsiSourceListGetInfoA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiSourceListGetInfoA"
c_MsiSourceListGetInfoA :: CString -> CString -> Int32 -> Word32 -> CString -> CString -> Ptr Word32 -> IO Word32
-- szProductCodeOrPatchCode : LPCSTR -> CString
-- szUserSid : LPCSTR optional -> CString
-- dwContext : MSIINSTALLCONTEXT -> Int32
-- dwOptions : DWORD -> Word32
-- szProperty : LPCSTR -> CString
-- szValue : LPSTR optional, out -> CString
-- pcchValue : DWORD* optional, in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msisourcelistgetinfoa =
foreign "MsiSourceListGetInfoA"
(string @-> string @-> int32_t @-> uint32_t @-> string @-> string @-> (ptr uint32_t) @-> returning uint32_t)
(* szProductCodeOrPatchCode : LPCSTR -> string *)
(* szUserSid : LPCSTR optional -> string *)
(* dwContext : MSIINSTALLCONTEXT -> int32_t *)
(* dwOptions : DWORD -> uint32_t *)
(* szProperty : LPCSTR -> string *)
(* szValue : LPSTR optional, out -> string *)
(* pcchValue : DWORD* optional, in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiSourceListGetInfoA" msi-source-list-get-info-a :convention :stdcall) :uint32
(sz-product-code-or-patch-code :string) ; LPCSTR
(sz-user-sid :string) ; LPCSTR optional
(dw-context :int32) ; MSIINSTALLCONTEXT
(dw-options :uint32) ; DWORD
(sz-property :string) ; LPCSTR
(sz-value :pointer) ; LPSTR optional, out
(pcch-value :pointer)) ; DWORD* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiSourceListGetInfoA = Win32::API::More->new('msi',
'DWORD MsiSourceListGetInfoA(LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, int dwContext, DWORD dwOptions, LPCSTR szProperty, LPSTR szValue, LPVOID pcchValue)');
# my $ret = $MsiSourceListGetInfoA->Call($szProductCodeOrPatchCode, $szUserSid, $dwContext, $dwOptions, $szProperty, $szValue, $pcchValue);
# szProductCodeOrPatchCode : LPCSTR -> LPCSTR
# szUserSid : LPCSTR optional -> LPCSTR
# dwContext : MSIINSTALLCONTEXT -> int
# dwOptions : DWORD -> DWORD
# szProperty : LPCSTR -> LPCSTR
# szValue : LPSTR optional, out -> LPSTR
# pcchValue : DWORD* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f MsiSourceListGetInfoW (Unicode版) — 製品やパッチのソースリストのプロパティ値を取得する。
- f MsiSourceListSetInfoA — 製品やパッチのソースリストのプロパティ値を設定する。