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

MsiSourceListAddMediaDiskW

関数
ソースリストにメディアディスクのラベルとプロンプトを登録する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiSourceListAddMediaDiskW(
    LPCWSTR szProductCodeOrPatchCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    DWORD dwDiskId,
    LPCWSTR szVolumeLabel,   // optional
    LPCWSTR szDiskPrompt   // optional
);

パラメーター

名前方向
szProductCodeOrPatchCodeLPCWSTRin
szUserSidLPCWSTRinoptional
dwContextMSIINSTALLCONTEXTin
dwOptionsDWORDin
dwDiskIdDWORDin
szVolumeLabelLPCWSTRinoptional
szDiskPromptLPCWSTRinoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiSourceListAddMediaDiskW(
    LPCWSTR szProductCodeOrPatchCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    DWORD dwDiskId,
    LPCWSTR szVolumeLabel,   // optional
    LPCWSTR szDiskPrompt   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiSourceListAddMediaDiskW(
    [MarshalAs(UnmanagedType.LPWStr)] string szProductCodeOrPatchCode,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string szUserSid,   // LPCWSTR optional
    int dwContext,   // MSIINSTALLCONTEXT
    uint dwOptions,   // DWORD
    uint dwDiskId,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string szVolumeLabel,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string szDiskPrompt   // LPCWSTR optional
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiSourceListAddMediaDiskW(
    <MarshalAs(UnmanagedType.LPWStr)> szProductCodeOrPatchCode As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> szUserSid As String,   ' LPCWSTR optional
    dwContext As Integer,   ' MSIINSTALLCONTEXT
    dwOptions As UInteger,   ' DWORD
    dwDiskId As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> szVolumeLabel As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> szDiskPrompt As String   ' LPCWSTR optional
) As UInteger
End Function
' szProductCodeOrPatchCode : LPCWSTR
' szUserSid : LPCWSTR optional
' dwContext : MSIINSTALLCONTEXT
' dwOptions : DWORD
' dwDiskId : DWORD
' szVolumeLabel : LPCWSTR optional
' szDiskPrompt : LPCWSTR optional
Declare PtrSafe Function MsiSourceListAddMediaDiskW Lib "msi" ( _
    ByVal szProductCodeOrPatchCode As LongPtr, _
    ByVal szUserSid As LongPtr, _
    ByVal dwContext As Long, _
    ByVal dwOptions As Long, _
    ByVal dwDiskId As Long, _
    ByVal szVolumeLabel As LongPtr, _
    ByVal szDiskPrompt 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

MsiSourceListAddMediaDiskW = ctypes.windll.msi.MsiSourceListAddMediaDiskW
MsiSourceListAddMediaDiskW.restype = wintypes.DWORD
MsiSourceListAddMediaDiskW.argtypes = [
    wintypes.LPCWSTR,  # szProductCodeOrPatchCode : LPCWSTR
    wintypes.LPCWSTR,  # szUserSid : LPCWSTR optional
    ctypes.c_int,  # dwContext : MSIINSTALLCONTEXT
    wintypes.DWORD,  # dwOptions : DWORD
    wintypes.DWORD,  # dwDiskId : DWORD
    wintypes.LPCWSTR,  # szVolumeLabel : LPCWSTR optional
    wintypes.LPCWSTR,  # szDiskPrompt : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiSourceListAddMediaDiskW = Fiddle::Function.new(
  lib['MsiSourceListAddMediaDiskW'],
  [
    Fiddle::TYPE_VOIDP,  # szProductCodeOrPatchCode : LPCWSTR
    Fiddle::TYPE_VOIDP,  # szUserSid : LPCWSTR optional
    Fiddle::TYPE_INT,  # dwContext : MSIINSTALLCONTEXT
    -Fiddle::TYPE_INT,  # dwOptions : DWORD
    -Fiddle::TYPE_INT,  # dwDiskId : DWORD
    Fiddle::TYPE_VOIDP,  # szVolumeLabel : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # szDiskPrompt : LPCWSTR optional
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiSourceListAddMediaDiskW(
        szProductCodeOrPatchCode: *const u16,  // LPCWSTR
        szUserSid: *const u16,  // LPCWSTR optional
        dwContext: i32,  // MSIINSTALLCONTEXT
        dwOptions: u32,  // DWORD
        dwDiskId: u32,  // DWORD
        szVolumeLabel: *const u16,  // LPCWSTR optional
        szDiskPrompt: *const u16  // LPCWSTR optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiSourceListAddMediaDiskW([MarshalAs(UnmanagedType.LPWStr)] string szProductCodeOrPatchCode, [MarshalAs(UnmanagedType.LPWStr)] string szUserSid, int dwContext, uint dwOptions, uint dwDiskId, [MarshalAs(UnmanagedType.LPWStr)] string szVolumeLabel, [MarshalAs(UnmanagedType.LPWStr)] string szDiskPrompt);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListAddMediaDiskW' -Namespace Win32 -PassThru
# $api::MsiSourceListAddMediaDiskW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwDiskId, szVolumeLabel, szDiskPrompt)
#uselib "msi.dll"
#func global MsiSourceListAddMediaDiskW "MsiSourceListAddMediaDiskW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; MsiSourceListAddMediaDiskW szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwDiskId, szVolumeLabel, szDiskPrompt   ; 戻り値は stat
; szProductCodeOrPatchCode : LPCWSTR -> "wptr"
; szUserSid : LPCWSTR optional -> "wptr"
; dwContext : MSIINSTALLCONTEXT -> "wptr"
; dwOptions : DWORD -> "wptr"
; dwDiskId : DWORD -> "wptr"
; szVolumeLabel : LPCWSTR optional -> "wptr"
; szDiskPrompt : LPCWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiSourceListAddMediaDiskW "MsiSourceListAddMediaDiskW" wstr, wstr, int, int, int, wstr, wstr
; res = MsiSourceListAddMediaDiskW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwDiskId, szVolumeLabel, szDiskPrompt)
; szProductCodeOrPatchCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; dwDiskId : DWORD -> "int"
; szVolumeLabel : LPCWSTR optional -> "wstr"
; szDiskPrompt : LPCWSTR optional -> "wstr"
; DWORD MsiSourceListAddMediaDiskW(LPCWSTR szProductCodeOrPatchCode, LPCWSTR szUserSid, MSIINSTALLCONTEXT dwContext, DWORD dwOptions, DWORD dwDiskId, LPCWSTR szVolumeLabel, LPCWSTR szDiskPrompt)
#uselib "msi.dll"
#cfunc global MsiSourceListAddMediaDiskW "MsiSourceListAddMediaDiskW" wstr, wstr, int, int, int, wstr, wstr
; res = MsiSourceListAddMediaDiskW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, dwDiskId, szVolumeLabel, szDiskPrompt)
; szProductCodeOrPatchCode : LPCWSTR -> "wstr"
; szUserSid : LPCWSTR optional -> "wstr"
; dwContext : MSIINSTALLCONTEXT -> "int"
; dwOptions : DWORD -> "int"
; dwDiskId : DWORD -> "int"
; szVolumeLabel : LPCWSTR optional -> "wstr"
; szDiskPrompt : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListAddMediaDiskW = msi.NewProc("MsiSourceListAddMediaDiskW")
)

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