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

MsiSourceListAddSourceA

関数
製品のソースリストにネットワークソースを追加する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiSourceListAddSourceA(
    LPCSTR szProduct,
    LPCSTR szUserName,   // optional
    DWORD dwReserved,   // optional
    LPCSTR szSource
);

パラメーター

名前方向
szProductLPCSTRin
szUserNameLPCSTRinoptional
dwReservedDWORDoptional
szSourceLPCSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiSourceListAddSourceA(
    LPCSTR szProduct,
    LPCSTR szUserName,   // optional
    DWORD dwReserved,   // optional
    LPCSTR szSource
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiSourceListAddSourceA(
    [MarshalAs(UnmanagedType.LPStr)] string szProduct,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szUserName,   // LPCSTR optional
    uint dwReserved,   // DWORD optional
    [MarshalAs(UnmanagedType.LPStr)] string szSource   // LPCSTR
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiSourceListAddSourceA(
    <MarshalAs(UnmanagedType.LPStr)> szProduct As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szUserName As String,   ' LPCSTR optional
    dwReserved As UInteger,   ' DWORD optional
    <MarshalAs(UnmanagedType.LPStr)> szSource As String   ' LPCSTR
) As UInteger
End Function
' szProduct : LPCSTR
' szUserName : LPCSTR optional
' dwReserved : DWORD optional
' szSource : LPCSTR
Declare PtrSafe Function MsiSourceListAddSourceA Lib "msi" ( _
    ByVal szProduct As String, _
    ByVal szUserName As String, _
    ByVal dwReserved As Long, _
    ByVal szSource As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiSourceListAddSourceA = ctypes.windll.msi.MsiSourceListAddSourceA
MsiSourceListAddSourceA.restype = wintypes.DWORD
MsiSourceListAddSourceA.argtypes = [
    wintypes.LPCSTR,  # szProduct : LPCSTR
    wintypes.LPCSTR,  # szUserName : LPCSTR optional
    wintypes.DWORD,  # dwReserved : DWORD optional
    wintypes.LPCSTR,  # szSource : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListAddSourceA = msi.NewProc("MsiSourceListAddSourceA")
)

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