MsiSourceListAddSourceExW
関数シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiSourceListAddSourceExW(
LPCWSTR szProductCodeOrPatchCode,
LPCWSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
DWORD dwOptions,
LPCWSTR szSource,
DWORD dwIndex
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| szProductCodeOrPatchCode | LPCWSTR | in | 製品またはパッチの ProductCode またはパッチ GUID。null 終端文字列を使用します。文字列が 39 文字を超える場合、この関数は失敗し ERROR_INVALID_PARAMETER を返します。このパラメーターを NULL にすることはできません。 | ||||||||||
| szUserSid | LPCWSTR | inoptional | このパラメーターには、製品またはパッチを保持するユーザーアカウントを指定する文字列形式の SID を指定できます。SID は検証も解決もされません。誤った SID を指定すると ERROR_UNKNOWN_PRODUCT または ERROR_UNKNOWN_PATCH が返ることがあります。マシンコンテキストを参照する場合、szUserSID は NULL でなければならず、dwContext は MSIINSTALLCONTEXT_MACHINE でなければなりません。
注意 特殊な SID 文字列 s-1-5-18 (system) は、コンピューター単位でインストールされた製品やパッチの列挙には使用できません。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 の値の解釈方法と、クリアするソースの種類を決定します。このパラメーターは、次の MSISOURCETYPE_* 定数のいずれか 1 つと、次の MSICODE_* 定数のいずれか 1 つを組み合わせたものでなければなりません。
| ||||||||||
| szSource | LPCWSTR | in | 追加または移動するソース。このパラメーターには、ファイル名を含まないパスのみを指定することが想定されています。 ファイル名は "PackageName" としてすでに登録されており、MsiSourceListSetInfo を通じて操作できます。この引数は必須です。 | ||||||||||
| dwIndex | DWORD | in | このパラメーターは、ソースの新しいインデックスを指定します。すべてのソースは、ソースリスト内で 1 から N まで(N はリスト内のソース数)のインデックスが付けられます。リスト内の各ソースは一意のインデックスを持ちます。 MsiSourceListAddSourceEx が新しいソースを指定し、dwIndex を 0 (ゼロ) に設定して呼び出された場合、新しいソースは既存のリストの末尾に追加されます。dwIndex が 0 に設定され、そのソースがすでにリストに存在する場合、リストは更新されません。 MsiSourceListAddSourceEx が新しいソースを指定し、dwIndex をソース数 (N) より小さい 0 以外の値に設定して呼び出された場合、新しいソースは指定したインデックスに配置され、その他のソースはインデックスが付け直されます。そのソースがすでに存在する場合、指定したインデックスに移動され、その他のソースはインデックスが付け直されます。 MsiSourceListAddSourceEx が新しいソースを指定し、dwIndex をソース数 (N) より大きい 0 以外の値に設定して呼び出された場合、新しいソースは既存のリストの末尾に追加されます。そのソースがすでに存在する場合、リストの末尾に移動され、その他のソースはインデックスが付け直されます。 |
戻り値の型: DWORD
公式ドキュメント
指定したコンテキストにおける、パッチまたは製品のソースの集合を追加または並べ替えます。指定したコンテキストに存在しないパッチに対して、ソースリストを新規作成することもできます。(Unicode)
戻り値
MsiSourceListAddSourceEx 関数は、次の値を返します。
| 値 | 意味 |
|---|---|
| ユーザーにソースを追加または移動する権限がありません。製品またはパッチが見つかったかどうかは示しません。 | |
| 構成データが破損しています。 | |
| Windows Installer サービスにアクセスできませんでした。 | |
| ソースが挿入または更新されました。 | |
| 指定した製品が不明です。 | |
| 指定したパッチが不明です。 | |
| 予期しない内部エラーが発生しました。 |
解説(Remarks)
管理者は、マシンコンテキストまたは自分自身のユーザー単位コンテキスト(管理対象または非管理対象)に存在する製品またはパッチインスタンスのインストールを変更できます。また、任意のユーザーのユーザー単位の管理対象 (per-user-managed) コンテキストに存在する製品またはパッチインスタンスのインストールを変更できます。管理者は、他のユーザーのユーザー単位の非管理対象 (per-user-unmanaged) コンテキストに存在する、そのユーザーによる製品またはパッチインスタンスのインストールを変更することはできません。
管理者以外のユーザーは、他のユーザーのユーザー単位コンテキスト(管理対象または非管理対象)に存在する製品またはパッチインスタンスのインストールを変更できません。自分自身のユーザー単位の非管理対象 (per-user-unmanaged) コンテキストに存在する製品またはパッチインスタンスのインストールは変更できます。マシンコンテキストまたは自分自身のユーザー単位の管理対象 (per-user-managed) コンテキストに存在する製品またはパッチインスタンスのインストールは、製品またはパッチのソースを参照することが許可されている場合に限り変更できます。ユーザーがソースを参照できるようにするには、ポリシーを設定します。詳細については、DisableBrowse、AllowLockdownBrowse、AlwaysInstallElevated の各ポリシーを参照してください。
msi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiSourceListAddSourceEx を定義します。エンコーディング非依存のエイリアスの使用と、エンコーディング非依存でないコードの使用を混在させると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiSourceListAddSourceExW(
LPCWSTR szProductCodeOrPatchCode,
LPCWSTR szUserSid, // optional
MSIINSTALLCONTEXT dwContext,
DWORD dwOptions,
LPCWSTR szSource,
DWORD dwIndex
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiSourceListAddSourceExW(
[MarshalAs(UnmanagedType.LPWStr)] string szProductCodeOrPatchCode, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szUserSid, // LPCWSTR optional
int dwContext, // MSIINSTALLCONTEXT
uint dwOptions, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string szSource, // LPCWSTR
uint dwIndex // DWORD
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiSourceListAddSourceExW(
<MarshalAs(UnmanagedType.LPWStr)> szProductCodeOrPatchCode As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szUserSid As String, ' LPCWSTR optional
dwContext As Integer, ' MSIINSTALLCONTEXT
dwOptions As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> szSource As String, ' LPCWSTR
dwIndex As UInteger ' DWORD
) As UInteger
End Function' szProductCodeOrPatchCode : LPCWSTR
' szUserSid : LPCWSTR optional
' dwContext : MSIINSTALLCONTEXT
' dwOptions : DWORD
' szSource : LPCWSTR
' dwIndex : DWORD
Declare PtrSafe Function MsiSourceListAddSourceExW Lib "msi" ( _
ByVal szProductCodeOrPatchCode As LongPtr, _
ByVal szUserSid As LongPtr, _
ByVal dwContext As Long, _
ByVal dwOptions As Long, _
ByVal szSource As LongPtr, _
ByVal dwIndex As Long) 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
MsiSourceListAddSourceExW = ctypes.windll.msi.MsiSourceListAddSourceExW
MsiSourceListAddSourceExW.restype = wintypes.DWORD
MsiSourceListAddSourceExW.argtypes = [
wintypes.LPCWSTR, # szProductCodeOrPatchCode : LPCWSTR
wintypes.LPCWSTR, # szUserSid : LPCWSTR optional
ctypes.c_int, # dwContext : MSIINSTALLCONTEXT
wintypes.DWORD, # dwOptions : DWORD
wintypes.LPCWSTR, # szSource : LPCWSTR
wintypes.DWORD, # dwIndex : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiSourceListAddSourceExW = Fiddle::Function.new(
lib['MsiSourceListAddSourceExW'],
[
Fiddle::TYPE_VOIDP, # szProductCodeOrPatchCode : LPCWSTR
Fiddle::TYPE_VOIDP, # szUserSid : LPCWSTR optional
Fiddle::TYPE_INT, # dwContext : MSIINSTALLCONTEXT
-Fiddle::TYPE_INT, # dwOptions : DWORD
Fiddle::TYPE_VOIDP, # szSource : LPCWSTR
-Fiddle::TYPE_INT, # dwIndex : DWORD
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiSourceListAddSourceExW(
szProductCodeOrPatchCode: *const u16, // LPCWSTR
szUserSid: *const u16, // LPCWSTR optional
dwContext: i32, // MSIINSTALLCONTEXT
dwOptions: u32, // DWORD
szSource: *const u16, // LPCWSTR
dwIndex: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiSourceListAddSourceExW([MarshalAs(UnmanagedType.LPWStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, int dwContext, uint dwOptions, [MarshalAs(UnmanagedType.LPWStr)] string szSource, uint dwIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListAddSourceExW' -Namespace Win32 -PassThru
# $api::MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)#uselib "msi.dll"
#func global MsiSourceListAddSourceExW "MsiSourceListAddSourceExW" wptr, wptr, wptr, wptr, wptr, wptr
; MsiSourceListAddSourceExW szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex ; 戻り値は stat
; szProductCodeOrPatchCode : LPCWSTR -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : MSIINSTALLCONTEXT -> "wptr"
; dwOptions : DWORD -> "wptr"
; szSource : LPCWSTR -> "wptr"
; dwIndex : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiSourceListAddSourceExW "MsiSourceListAddSourceExW" wstr, wstr, int, int, wstr, int
; res = MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
; szProductCodeOrPatchCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; szSource : LPCWSTR -> "wstr"
; dwIndex : DWORD -> "int"; DWORD MsiSourceListAddSourceExW(LPCWSTR szProductCodeOrPatchCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, LPCWSTR szSource, DWORD dwIndex)
#uselib "msi.dll"
#cfunc global MsiSourceListAddSourceExW "MsiSourceListAddSourceExW" wstr, wstr, int, int, wstr, int
; res = MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
; szProductCodeOrPatchCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; szSource : LPCWSTR -> "wstr"
; dwIndex : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiSourceListAddSourceExW = msi.NewProc("MsiSourceListAddSourceExW")
)
// szProductCodeOrPatchCode (LPCWSTR), szUserSid (LPCWSTR optional), dwContext (MSIINSTALLCONTEXT), dwOptions (DWORD), szSource (LPCWSTR), dwIndex (DWORD)
r1, _, err := procMsiSourceListAddSourceExW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProductCodeOrPatchCode))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szUserSid))),
uintptr(dwContext),
uintptr(dwOptions),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szSource))),
uintptr(dwIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiSourceListAddSourceExW(
szProductCodeOrPatchCode: PWideChar; // LPCWSTR
szUserSid: PWideChar; // LPCWSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT
dwOptions: DWORD; // DWORD
szSource: PWideChar; // LPCWSTR
dwIndex: DWORD // DWORD
): DWORD; stdcall;
external 'msi.dll' name 'MsiSourceListAddSourceExW';result := DllCall("msi\MsiSourceListAddSourceExW"
, "WStr", szProductCodeOrPatchCode ; LPCWSTR
, "WStr", szUserSid ; LPCWSTR optional
, "Int", dwContext ; MSIINSTALLCONTEXT
, "UInt", dwOptions ; DWORD
, "WStr", szSource ; LPCWSTR
, "UInt", dwIndex ; DWORD
, "UInt") ; return: DWORD●MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex) = DLL("msi.dll", "dword MsiSourceListAddSourceExW(char*, char*, int, dword, char*, dword)")
# 呼び出し: MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
# szProductCodeOrPatchCode : LPCWSTR -> "char*"
# szUserSid : LPCWSTR optional -> "char*"
# dwContext : MSIINSTALLCONTEXT -> "int"
# dwOptions : DWORD -> "dword"
# szSource : LPCWSTR -> "char*"
# dwIndex : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "msi" fn MsiSourceListAddSourceExW(
szProductCodeOrPatchCode: [*c]const u16, // LPCWSTR
szUserSid: [*c]const u16, // LPCWSTR optional
dwContext: i32, // MSIINSTALLCONTEXT
dwOptions: u32, // DWORD
szSource: [*c]const u16, // LPCWSTR
dwIndex: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc MsiSourceListAddSourceExW(
szProductCodeOrPatchCode: WideCString, # LPCWSTR
szUserSid: WideCString, # LPCWSTR optional
dwContext: int32, # MSIINSTALLCONTEXT
dwOptions: uint32, # DWORD
szSource: WideCString, # LPCWSTR
dwIndex: uint32 # DWORD
): uint32 {.importc: "MsiSourceListAddSourceExW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "msi");
extern(Windows)
uint MsiSourceListAddSourceExW(
const(wchar)* szProductCodeOrPatchCode, // LPCWSTR
const(wchar)* szUserSid, // LPCWSTR optional
int dwContext, // MSIINSTALLCONTEXT
uint dwOptions, // DWORD
const(wchar)* szSource, // LPCWSTR
uint dwIndex // DWORD
);ccall((:MsiSourceListAddSourceExW, "msi.dll"), stdcall, UInt32,
(Cwstring, Cwstring, Int32, UInt32, Cwstring, UInt32),
szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
# szProductCodeOrPatchCode : LPCWSTR -> Cwstring
# szUserSid : LPCWSTR optional -> Cwstring
# dwContext : MSIINSTALLCONTEXT -> Int32
# dwOptions : DWORD -> UInt32
# szSource : LPCWSTR -> Cwstring
# dwIndex : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiSourceListAddSourceExW(
const uint16_t* szProductCodeOrPatchCode,
const uint16_t* szUserSid,
int32_t dwContext,
uint32_t dwOptions,
const uint16_t* szSource,
uint32_t dwIndex);
]]
local msi = ffi.load("msi")
-- msi.MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
-- szProductCodeOrPatchCode : LPCWSTR
-- szUserSid : LPCWSTR optional
-- dwContext : MSIINSTALLCONTEXT
-- dwOptions : DWORD
-- szSource : LPCWSTR
-- dwIndex : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiSourceListAddSourceExW = lib.func('__stdcall', 'MsiSourceListAddSourceExW', 'uint32_t', ['str16', 'str16', 'int32_t', 'uint32_t', 'str16', 'uint32_t']);
// MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
// szProductCodeOrPatchCode : LPCWSTR -> 'str16'
// szUserSid : LPCWSTR optional -> 'str16'
// dwContext : MSIINSTALLCONTEXT -> 'int32_t'
// dwOptions : DWORD -> 'uint32_t'
// szSource : LPCWSTR -> 'str16'
// dwIndex : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("msi.dll", {
MsiSourceListAddSourceExW: { parameters: ["buffer", "buffer", "i32", "u32", "buffer", "u32"], result: "u32" },
});
// lib.symbols.MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex)
// szProductCodeOrPatchCode : LPCWSTR -> "buffer"
// szUserSid : LPCWSTR optional -> "buffer"
// dwContext : MSIINSTALLCONTEXT -> "i32"
// dwOptions : DWORD -> "u32"
// szSource : LPCWSTR -> "buffer"
// dwIndex : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiSourceListAddSourceExW(
const uint16_t* szProductCodeOrPatchCode,
const uint16_t* szUserSid,
int32_t dwContext,
uint32_t dwOptions,
const uint16_t* szSource,
uint32_t dwIndex);
C, "msi.dll");
// $ffi->MsiSourceListAddSourceExW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource, dwIndex);
// szProductCodeOrPatchCode : LPCWSTR
// szUserSid : LPCWSTR optional
// dwContext : MSIINSTALLCONTEXT
// dwOptions : DWORD
// szSource : LPCWSTR
// dwIndex : DWORD
// 構造体/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.UNICODE_OPTIONS);
int MsiSourceListAddSourceExW(
WString szProductCodeOrPatchCode, // LPCWSTR
WString szUserSid, // LPCWSTR optional
int dwContext, // MSIINSTALLCONTEXT
int dwOptions, // DWORD
WString szSource, // LPCWSTR
int dwIndex // DWORD
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("msi")]
lib Libmsi
fun MsiSourceListAddSourceExW = MsiSourceListAddSourceExW(
szProductCodeOrPatchCode : UInt16*, # LPCWSTR
szUserSid : UInt16*, # LPCWSTR optional
dwContext : Int32, # MSIINSTALLCONTEXT
dwOptions : UInt32, # DWORD
szSource : UInt16*, # LPCWSTR
dwIndex : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MsiSourceListAddSourceExWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Int32, Uint32, Pointer<Utf16>, Uint32);
typedef MsiSourceListAddSourceExWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, int, Pointer<Utf16>, int);
final MsiSourceListAddSourceExW = DynamicLibrary.open('msi.dll')
.lookupFunction<MsiSourceListAddSourceExWNative, MsiSourceListAddSourceExWDart>('MsiSourceListAddSourceExW');
// szProductCodeOrPatchCode : LPCWSTR -> Pointer<Utf16>
// szUserSid : LPCWSTR optional -> Pointer<Utf16>
// dwContext : MSIINSTALLCONTEXT -> Int32
// dwOptions : DWORD -> Uint32
// szSource : LPCWSTR -> Pointer<Utf16>
// dwIndex : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MsiSourceListAddSourceExW(
szProductCodeOrPatchCode: PWideChar; // LPCWSTR
szUserSid: PWideChar; // LPCWSTR optional
dwContext: Integer; // MSIINSTALLCONTEXT
dwOptions: DWORD; // DWORD
szSource: PWideChar; // LPCWSTR
dwIndex: DWORD // DWORD
): DWORD; stdcall;
external 'msi.dll' name 'MsiSourceListAddSourceExW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MsiSourceListAddSourceExW"
c_MsiSourceListAddSourceExW :: CWString -> CWString -> Int32 -> Word32 -> CWString -> Word32 -> IO Word32
-- szProductCodeOrPatchCode : LPCWSTR -> CWString
-- szUserSid : LPCWSTR optional -> CWString
-- dwContext : MSIINSTALLCONTEXT -> Int32
-- dwOptions : DWORD -> Word32
-- szSource : LPCWSTR -> CWString
-- dwIndex : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let msisourcelistaddsourceexw =
foreign "MsiSourceListAddSourceExW"
((ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> uint32_t @-> (ptr uint16_t) @-> uint32_t @-> returning uint32_t)
(* szProductCodeOrPatchCode : LPCWSTR -> (ptr uint16_t) *)
(* szUserSid : LPCWSTR optional -> (ptr uint16_t) *)
(* dwContext : MSIINSTALLCONTEXT -> int32_t *)
(* dwOptions : DWORD -> uint32_t *)
(* szSource : LPCWSTR -> (ptr uint16_t) *)
(* dwIndex : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)
(cffi:defcfun ("MsiSourceListAddSourceExW" msi-source-list-add-source-ex-w :convention :stdcall) :uint32
(sz-product-code-or-patch-code (:string :encoding :utf-16le)) ; LPCWSTR
(sz-user-sid (:string :encoding :utf-16le)) ; LPCWSTR optional
(dw-context :int32) ; MSIINSTALLCONTEXT
(dw-options :uint32) ; DWORD
(sz-source (:string :encoding :utf-16le)) ; LPCWSTR
(dw-index :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MsiSourceListAddSourceExW = Win32::API::More->new('msi',
'DWORD MsiSourceListAddSourceExW(LPCWSTR szProductCodeOrPatchCode, LPCWSTR szUserSid, int dwContext, DWORD dwOptions, LPCWSTR szSource, DWORD dwIndex)');
# my $ret = $MsiSourceListAddSourceExW->Call($szProductCodeOrPatchCode, $szUserSid, $dwContext, $dwOptions, $szSource, $dwIndex);
# szProductCodeOrPatchCode : LPCWSTR -> LPCWSTR
# szUserSid : LPCWSTR optional -> LPCWSTR
# dwContext : MSIINSTALLCONTEXT -> int
# dwOptions : DWORD -> DWORD
# szSource : LPCWSTR -> LPCWSTR
# dwIndex : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
- f MsiSourceListAddSourceExA (ANSI版) — コンテキストや種別を指定して製品やパッチのソースを追加する。
- f MsiSourceListAddSourceW — 製品のソースリストにネットワークソースを追加する。
- f MsiSourceListSetInfoW — 製品やパッチのソースリストのプロパティ値を設定する。