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

MsiSourceListEnumSourcesW

関数
製品やパッチのソースリスト内のソースを列挙する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiSourceListEnumSourcesW(
    LPCWSTR szProductCodeOrPatchCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    DWORD dwIndex,
    LPWSTR szSource,   // optional
    DWORD* pcchSource   // optional
);

パラメーター

名前方向
szProductCodeOrPatchCodeLPCWSTRin
szUserSidLPCWSTRinoptional
dwContextMSIINSTALLCONTEXTin
dwOptionsDWORDin
dwIndexDWORDin
szSourceLPWSTRoutoptional
pcchSourceDWORD*inoutoptional

戻り値の型: DWORD

各言語での呼び出し定義

// msi.dll  (Unicode / -W)
#include <windows.h>

DWORD MsiSourceListEnumSourcesW(
    LPCWSTR szProductCodeOrPatchCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    DWORD dwIndex,
    LPWSTR szSource,   // optional
    DWORD* pcchSource   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiSourceListEnumSourcesW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProductCodeOrPatchCode,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szUserSid,   // LPCWSTR optional
    int dwContext,   // MSIINSTALLCONTEXT
    uint dwOptions,   // DWORD
    uint dwIndex,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szSource,   // LPWSTR optional, out
    IntPtr pcchSource   // DWORD* optional, in/out
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiSourceListEnumSourcesW(
    <MarshalAs(UnmanagedType.LPWStr)> szProductCodeOrPatchCode As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szUserSid As String,   ' LPCWSTR optional
    dwContext As Integer,   ' MSIINSTALLCONTEXT
    dwOptions As UInteger,   ' DWORD
    dwIndex As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> szSource As System.Text.StringBuilder,   ' LPWSTR optional, out
    pcchSource As IntPtr   ' DWORD* optional, in/out
) As UInteger
End Function
' szProductCodeOrPatchCode : LPCWSTR
' szUserSid : LPCWSTR optional
' dwContext : MSIINSTALLCONTEXT
' dwOptions : DWORD
' dwIndex : DWORD
' szSource : LPWSTR optional, out
' pcchSource : DWORD* optional, in/out
Declare PtrSafe Function MsiSourceListEnumSourcesW Lib "msi" ( _
    ByVal szProductCodeOrPatchCode As LongPtr, _
    ByVal szUserSid As LongPtr, _
    ByVal dwContext As Long, _
    ByVal dwOptions As Long, _
    ByVal dwIndex As Long, _
    ByVal szSource As LongPtr, _
    ByVal pcchSource 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

MsiSourceListEnumSourcesW = ctypes.windll.msi.MsiSourceListEnumSourcesW
MsiSourceListEnumSourcesW.restype = wintypes.DWORD
MsiSourceListEnumSourcesW.argtypes = [
    wintypes.LPCWSTR,  # szProductCodeOrPatchCode : LPCWSTR
    wintypes.LPCWSTR,  # szUserSid : LPCWSTR optional
    ctypes.c_int,  # dwContext : MSIINSTALLCONTEXT
    wintypes.DWORD,  # dwOptions : DWORD
    wintypes.DWORD,  # dwIndex : DWORD
    wintypes.LPWSTR,  # szSource : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # pcchSource : DWORD* optional, in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiSourceListEnumSourcesW = Fiddle::Function.new(
  lib['MsiSourceListEnumSourcesW'],
  [
    Fiddle::TYPE_VOIDP,  # szProductCodeOrPatchCode : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szUserSid : LPCWSTR optional
    Fiddle::TYPE_INT,  # dwContext : MSIINSTALLCONTEXT
    -Fiddle::TYPE_INT,  # dwOptions : DWORD
    -Fiddle::TYPE_INT,  # dwIndex : DWORD
    Fiddle::TYPE_VOIDP,  # szSource : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # pcchSource : DWORD* optional, in/out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiSourceListEnumSourcesW(
        szProductCodeOrPatchCode: *const u16,  // LPCWSTR
        szUserSid: *const u16,  // LPCWSTR optional
        dwContext: i32,  // MSIINSTALLCONTEXT
        dwOptions: u32,  // DWORD
        dwIndex: u32,  // DWORD
        szSource: *mut u16,  // LPWSTR optional, out
        pcchSource: *mut u32  // DWORD* optional, in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiSourceListEnumSourcesW([MarshalAs(UnmanagedType.LPWStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, int dwContext, uint dwOptions, uint dwIndex, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder szSource, IntPtr pcchSource);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListEnumSourcesW' -Namespace Win32 -PassThru
# $api::MsiSourceListEnumSourcesW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwIndex, szSource, pcchSource)
#uselib "msi.dll"
#func global MsiSourceListEnumSourcesW "MsiSourceListEnumSourcesW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; MsiSourceListEnumSourcesW szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwIndex, varptr(szSource), varptr(pcchSource)   ; 戻り値は stat
; szProductCodeOrPatchCode : LPCWSTR -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : MSIINSTALLCONTEXT -> "wptr"
; dwOptions : DWORD -> "wptr"
; dwIndex : DWORD -> "wptr"
; szSource : LPWSTR optional, out -> "wptr"
; pcchSource : DWORD* optional, in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "msi.dll"
#cfunc global MsiSourceListEnumSourcesW "MsiSourceListEnumSourcesW" wstr, wstr, int, int, int, var, var
; res = MsiSourceListEnumSourcesW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwIndex, szSource, pcchSource)
; szProductCodeOrPatchCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; dwIndex : DWORD -> "int"
; szSource : LPWSTR optional, out -> "var"
; pcchSource : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD MsiSourceListEnumSourcesW(LPCWSTR szProductCodeOrPatchCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwIndex, LPWSTR szSource, DWORD* pcchSource)
#uselib "msi.dll"
#cfunc global MsiSourceListEnumSourcesW "MsiSourceListEnumSourcesW" wstr, wstr, int, int, int, var, var
; res = MsiSourceListEnumSourcesW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwIndex, szSource, pcchSource)
; szProductCodeOrPatchCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; dwIndex : DWORD -> "int"
; szSource : LPWSTR optional, out -> "var"
; pcchSource : DWORD* optional, in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListEnumSourcesW = msi.NewProc("MsiSourceListEnumSourcesW")
)

// szProductCodeOrPatchCode (LPCWSTR), szUserSid (LPCWSTR optional), dwContext (MSIINSTALLCONTEXT), dwOptions (DWORD), dwIndex (DWORD), szSource (LPWSTR optional, out), pcchSource (DWORD* optional, in/out)
r1, _, err := procMsiSourceListEnumSourcesW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCodeOrPatchCode))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szUserSid))),
	uintptr(dwContext),
	uintptr(dwOptions),
	uintptr(dwIndex),
	uintptr(szSource),
	uintptr(pcchSource),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiSourceListEnumSourcesW(
  szProductCodeOrPatchCode: PWideChar;   // LPCWSTR
  szUserSid: PWideChar;   // LPCWSTR optional
  dwContext: Integer;   // MSIINSTALLCONTEXT
  dwOptions: DWORD;   // DWORD
  dwIndex: DWORD;   // DWORD
  szSource: PWideChar;   // LPWSTR optional, out
  pcchSource: Pointer   // DWORD* optional, in/out
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListEnumSourcesW';
result := DllCall("msi\MsiSourceListEnumSourcesW"
    , "WStr", szProductCodeOrPatchCode   ; LPCWSTR
    , "WStr", szUserSid   ; LPCWSTR optional
    , "Int", dwContext   ; MSIINSTALLCONTEXT
    , "UInt", dwOptions   ; DWORD
    , "UInt", dwIndex   ; DWORD
    , "Ptr", szSource   ; LPWSTR optional, out
    , "Ptr", pcchSource   ; DWORD* optional, in/out
    , "UInt")   ; return: DWORD
●MsiSourceListEnumSourcesW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwIndex, szSource, pcchSource) = DLL("msi.dll", "dword MsiSourceListEnumSourcesW(char*, char*, int, dword, dword, char*, void*)")
# 呼び出し: MsiSourceListEnumSourcesW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwIndex, szSource, pcchSource)
# szProductCodeOrPatchCode : LPCWSTR -> "char*"
# szUserSid : LPCWSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# dwOptions : DWORD -> "dword"
# dwIndex : DWORD -> "dword"
# szSource : LPWSTR optional, out -> "char*"
# pcchSource : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。