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

MsiSourceListAddSourceExA

関数
コンテキストや種別を指定して製品やパッチのソースを追加する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiSourceListAddSourceExA(
    LPCSTR szProductCodeOrPatchCode,
    LPCSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    LPCSTR szSource,
    DWORD dwIndex
);

パラメーター

名前方向
szProductCodeOrPatchCodeLPCSTRin
szUserSidLPCSTRinoptional
dwContextMSIINSTALLCONTEXTin
dwOptionsDWORDin
szSourceLPCSTRin
dwIndexDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiSourceListAddSourceExA(
    LPCSTR szProductCodeOrPatchCode,
    LPCSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    LPCSTR szSource,
    DWORD dwIndex
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiSourceListAddSourceExA(
    [MarshalAs(UnmanagedType.LPStr)] string szProductCodeOrPatchCode,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szUserSid,   // LPCSTR optional
    int dwContext,   // MSIINSTALLCONTEXT
    uint dwOptions,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string szSource,   // LPCSTR
    uint dwIndex   // DWORD
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiSourceListAddSourceExA(
    <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)> szSource As String,   ' LPCSTR
    dwIndex As UInteger   ' DWORD
) As UInteger
End Function
' szProductCodeOrPatchCode : LPCSTR
' szUserSid : LPCSTR optional
' dwContext : MSIINSTALLCONTEXT
' dwOptions : DWORD
' szSource : LPCSTR
' dwIndex : DWORD
Declare PtrSafe Function MsiSourceListAddSourceExA Lib "msi" ( _
    ByVal szProductCodeOrPatchCode As String, _
    ByVal szUserSid As String, _
    ByVal dwContext As Long, _
    ByVal dwOptions As Long, _
    ByVal szSource As String, _
    ByVal dwIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiSourceListAddSourceExA = ctypes.windll.msi.MsiSourceListAddSourceExA
MsiSourceListAddSourceExA.restype = wintypes.DWORD
MsiSourceListAddSourceExA.argtypes = [
    wintypes.LPCSTR,  # szProductCodeOrPatchCode : LPCSTR
    wintypes.LPCSTR,  # szUserSid : LPCSTR optional
    ctypes.c_int,  # dwContext : MSIINSTALLCONTEXT
    wintypes.DWORD,  # dwOptions : DWORD
    wintypes.LPCSTR,  # szSource : LPCSTR
    wintypes.DWORD,  # dwIndex : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiSourceListAddSourceExA = Fiddle::Function.new(
  lib['MsiSourceListAddSourceExA'],
  [
    Fiddle::TYPE_VOIDP,  # szProductCodeOrPatchCode : LPCSTR
    Fiddle::TYPE_VOIDP,  # szUserSid : LPCSTR optional
    Fiddle::TYPE_INT,  # dwContext : MSIINSTALLCONTEXT
    -Fiddle::TYPE_INT,  # dwOptions : DWORD
    Fiddle::TYPE_VOIDP,  # szSource : LPCSTR
    -Fiddle::TYPE_INT,  # dwIndex : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiSourceListAddSourceExA(
        szProductCodeOrPatchCode: *const u8,  // LPCSTR
        szUserSid: *const u8,  // LPCSTR optional
        dwContext: i32,  // MSIINSTALLCONTEXT
        dwOptions: u32,  // DWORD
        szSource: *const u8,  // LPCSTR
        dwIndex: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiSourceListAddSourceExA([MarshalAs(UnmanagedType.LPStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPStr)] string szUserSid, int dwContext, uint dwOptions, [MarshalAs(UnmanagedType.LPStr)] string szSource, uint dwIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListAddSourceExA' -Namespace Win32 -PassThru
# $api::MsiSourceListAddSourceExA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
#uselib "msi.dll"
#func global MsiSourceListAddSourceExA "MsiSourceListAddSourceExA" sptr, sptr, sptr, sptr, sptr, sptr
; MsiSourceListAddSourceExA szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex   ; 戻り値は stat
; szProductCodeOrPatchCode : LPCSTR -> "sptr"
; szUserSid : LPCSTR optional -> "sptr"
; dwContext : MSIINSTALLCONTEXT -> "sptr"
; dwOptions : DWORD -> "sptr"
; szSource : LPCSTR -> "sptr"
; dwIndex : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiSourceListAddSourceExA "MsiSourceListAddSourceExA" str, str, int, int, str, int
; res = MsiSourceListAddSourceExA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
; szProductCodeOrPatchCode : LPCSTR -> "str"
; szUserSid : LPCSTR optional -> "str"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; szSource : LPCSTR -> "str"
; dwIndex : DWORD -> "int"
; DWORD MsiSourceListAddSourceExA(LPCSTR szProductCodeOrPatchCode, LPCSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCSTR szSource, DWORD dwIndex)
#uselib "msi.dll"
#cfunc global MsiSourceListAddSourceExA "MsiSourceListAddSourceExA" str, str, int, int, str, int
; res = MsiSourceListAddSourceExA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
; szProductCodeOrPatchCode : LPCSTR -> "str"
; szUserSid : LPCSTR optional -> "str"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; szSource : LPCSTR -> "str"
; dwIndex : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListAddSourceExA = msi.NewProc("MsiSourceListAddSourceExA")
)

// szProductCodeOrPatchCode (LPCSTR), szUserSid (LPCSTR optional), dwContext (MSIINSTALLCONTEXT), dwOptions (DWORD), szSource (LPCSTR), dwIndex (DWORD)
r1, _, err := procMsiSourceListAddSourceExA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szProductCodeOrPatchCode))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szUserSid))),
	uintptr(dwContext),
	uintptr(dwOptions),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szSource))),
	uintptr(dwIndex),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiSourceListAddSourceExA(
  szProductCodeOrPatchCode: PAnsiChar;   // LPCSTR
  szUserSid: PAnsiChar;   // LPCSTR optional
  dwContext: Integer;   // MSIINSTALLCONTEXT
  dwOptions: DWORD;   // DWORD
  szSource: PAnsiChar;   // LPCSTR
  dwIndex: DWORD   // DWORD
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListAddSourceExA';
result := DllCall("msi\MsiSourceListAddSourceExA"
    , "AStr", szProductCodeOrPatchCode   ; LPCSTR
    , "AStr", szUserSid   ; LPCSTR optional
    , "Int", dwContext   ; MSIINSTALLCONTEXT
    , "UInt", dwOptions   ; DWORD
    , "AStr", szSource   ; LPCSTR
    , "UInt", dwIndex   ; DWORD
    , "UInt")   ; return: DWORD
●MsiSourceListAddSourceExA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex) = DLL("msi.dll", "dword MsiSourceListAddSourceExA(char*, char*, int, dword, char*, dword)")
# 呼び出し: MsiSourceListAddSourceExA(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
# szProductCodeOrPatchCode : LPCSTR -> "char*"
# szUserSid : LPCSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# dwOptions : DWORD -> "dword"
# szSource : LPCSTR -> "char*"
# dwIndex : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。