ホーム › System.ApplicationInstallationAndServicing › MsiSourceListAddSourceW
MsiSourceListAddSourceW
関数製品のソースリストにネットワークソースを追加する。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiSourceListAddSourceW(
LPCWSTR szProduct,
LPCWSTR szUserName, // optional
DWORD dwReserved, // optional
LPCWSTR szSource
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szProduct | LPCWSTR | in |
| szUserName | LPCWSTR | inoptional |
| dwReserved | DWORD | optional |
| szSource | LPCWSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiSourceListAddSourceW(
LPCWSTR szProduct,
LPCWSTR szUserName, // optional
DWORD dwReserved, // optional
LPCWSTR szSource
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiSourceListAddSourceW(
[MarshalAs(UnmanagedType.LPWStr)] string szProduct, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szUserName, // LPCWSTR optional
uint dwReserved, // DWORD optional
[MarshalAs(UnmanagedType.LPWStr)] string szSource // LPCWSTR
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiSourceListAddSourceW(
<MarshalAs(UnmanagedType.LPWStr)> szProduct As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szUserName As String, ' LPCWSTR optional
dwReserved As UInteger, ' DWORD optional
<MarshalAs(UnmanagedType.LPWStr)> szSource As String ' LPCWSTR
) As UInteger
End Function' szProduct : LPCWSTR
' szUserName : LPCWSTR optional
' dwReserved : DWORD optional
' szSource : LPCWSTR
Declare PtrSafe Function MsiSourceListAddSourceW Lib "msi" ( _
ByVal szProduct As LongPtr, _
ByVal szUserName As LongPtr, _
ByVal dwReserved As Long, _
ByVal szSource 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
MsiSourceListAddSourceW = ctypes.windll.msi.MsiSourceListAddSourceW
MsiSourceListAddSourceW.restype = wintypes.DWORD
MsiSourceListAddSourceW.argtypes = [
wintypes.LPCWSTR, # szProduct : LPCWSTR
wintypes.LPCWSTR, # szUserName : LPCWSTR optional
wintypes.DWORD, # dwReserved : DWORD optional
wintypes.LPCWSTR, # szSource : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiSourceListAddSourceW = Fiddle::Function.new(
lib['MsiSourceListAddSourceW'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCWSTR
Fiddle::TYPE_VOIDP, # szUserName : LPCWSTR optional
-Fiddle::TYPE_INT, # dwReserved : DWORD optional
Fiddle::TYPE_VOIDP, # szSource : LPCWSTR
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiSourceListAddSourceW(
szProduct: *const u16, // LPCWSTR
szUserName: *const u16, // LPCWSTR optional
dwReserved: u32, // DWORD optional
szSource: *const u16 // LPCWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiSourceListAddSourceW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, uint dwReserved, [MarshalAs(UnmanagedType.LPWStr)] string szSource);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListAddSourceW' -Namespace Win32 -PassThru
# $api::MsiSourceListAddSourceW(szProduct, szUserName, dwReserved, szSource)#uselib "msi.dll"
#func global MsiSourceListAddSourceW "MsiSourceListAddSourceW" wptr, wptr, wptr, wptr
; MsiSourceListAddSourceW szProduct, szUserName, dwReserved, szSource ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; szUserName : LPCWSTR optional -> "wptr"
; dwReserved : DWORD optional -> "wptr"
; szSource : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiSourceListAddSourceW "MsiSourceListAddSourceW" wstr, wstr, int, wstr
; res = MsiSourceListAddSourceW(szProduct, szUserName, dwReserved, szSource)
; szProduct : LPCWSTR -> "wstr"
; szUserName : LPCWSTR optional -> "wstr"
; dwReserved : DWORD optional -> "int"
; szSource : LPCWSTR -> "wstr"; DWORD MsiSourceListAddSourceW(LPCWSTR szProduct, LPCWSTR szUserName, DWORD dwReserved, LPCWSTR szSource)
#uselib "msi.dll"
#cfunc global MsiSourceListAddSourceW "MsiSourceListAddSourceW" wstr, wstr, int, wstr
; res = MsiSourceListAddSourceW(szProduct, szUserName, dwReserved, szSource)
; szProduct : LPCWSTR -> "wstr"
; szUserName : LPCWSTR optional -> "wstr"
; dwReserved : DWORD optional -> "int"
; szSource : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiSourceListAddSourceW = msi.NewProc("MsiSourceListAddSourceW")
)
// szProduct (LPCWSTR), szUserName (LPCWSTR optional), dwReserved (DWORD optional), szSource (LPCWSTR)
r1, _, err := procMsiSourceListAddSourceW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szUserName))),
uintptr(dwReserved),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szSource))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiSourceListAddSourceW(
szProduct: PWideChar; // LPCWSTR
szUserName: PWideChar; // LPCWSTR optional
dwReserved: DWORD; // DWORD optional
szSource: PWideChar // LPCWSTR
): DWORD; stdcall;
external 'msi.dll' name 'MsiSourceListAddSourceW';result := DllCall("msi\MsiSourceListAddSourceW"
, "WStr", szProduct ; LPCWSTR
, "WStr", szUserName ; LPCWSTR optional
, "UInt", dwReserved ; DWORD optional
, "WStr", szSource ; LPCWSTR
, "UInt") ; return: DWORD●MsiSourceListAddSourceW(szProduct, szUserName, dwReserved, szSource) = DLL("msi.dll", "dword MsiSourceListAddSourceW(char*, char*, dword, char*)")
# 呼び出し: MsiSourceListAddSourceW(szProduct, szUserName, dwReserved, szSource)
# szProduct : LPCWSTR -> "char*"
# szUserName : LPCWSTR optional -> "char*"
# dwReserved : DWORD optional -> "dword"
# szSource : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。