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

MsiSourceListClearMediaDiskW

関数
ソースリストから指定IDのメディアディスク登録を削除する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiSourceListClearMediaDiskW(
    LPCWSTR szProductCodeOrPatchCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    DWORD dwDiskId
);

パラメーター

名前方向
szProductCodeOrPatchCodeLPCWSTRin
szUserSidLPCWSTRinoptional
dwContextMSIINSTALLCONTEXTin
dwOptionsDWORDin
dwDiskIdDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

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

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListClearMediaDiskW = msi.NewProc("MsiSourceListClearMediaDiskW")
)

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