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

MsiSourceListClearSourceW

関数
製品やパッチのソースリストから指定したソースを削除する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiSourceListClearSourceW(
    LPCWSTR szProductCodeOrPatchCode,
    LPCWSTR szUserSid,   // optional
    MSIINSTALLCONTEXT dwContext,
    DWORD dwOptions,
    LPCWSTR szSource
);

パラメーター

名前方向説明
szProductCodeOrPatchCodeLPCWSTRin製品またはパッチの ProductCode またはパッチ GUID。null 終端文字列を使用します。文字列が 39 文字より長い場合、この関数は失敗し ERROR_INVALID_PARAMETER を返します。このパラメーターを NULL にすることはできません。
szUserSidLPCWSTRinoptional

このパラメーターには、製品またはパッチを保持するユーザーアカウントを指定する文字列 SID を指定できます。SID は検証も解決もされません。誤った SID を指定すると ERROR_UNKNOWN_PRODUCT または ERROR_UNKNOWN_PATCH が返ることがあります。マシンコンテキストを参照する場合、szUserSIDNULL であり、dwContextMSIINSTALLCONTEXT_MACHINE である必要があります。

SID の種類 意味
NULL
NULL は現在ログオンしているユーザーを表します。現在のユーザーアカウントを参照する場合、szUserSIDNULL にでき、dwContextMSIINSTALLCONTEXT_USERMANAGED または MSIINSTALLCONTEXT_USERUNMANAGED にできます。
User SID
システム内の特定のユーザーに対する列挙を指定します。ユーザー SID の例としては "S-1-3-64-2415071341-1358098788-3127455600-2561" があります。
Note 特殊な SID 文字列 "S-1-5-18"(システム)は、マシン単位でインストールされた製品またはパッチの列挙には使用できません。SID 値を "S-1-5-18" に設定すると ERROR_INVALID_PARAMETER が返ります。
Note 特殊な SID 文字列 "S-1-1-0"(Everyone)は使用しないでください。SID 値を "S-1-1-0" に設定すると失敗し、ERROR_INVALID_PARAM が返ります。
dwContextMSIINSTALLCONTEXTin

このパラメーターは、製品またはパッチのインスタンスのコンテキストを指定します。次のいずれかの値を指定できます。

コンテキストの種類 意味
MSIINSTALLCONTEXT_USERMANAGED
製品またはパッチのインスタンスはユーザー単位の管理対象コンテキストに存在します。
MSIINSTALLCONTEXT_USERUNMANAGED
製品またはパッチのインスタンスはユーザー単位の非管理対象コンテキストに存在します。
MSIINSTALLCONTEXT_MACHINE
製品またはパッチのインスタンスはマシン単位のコンテキストに存在します。
dwOptionsDWORDin

dwOptions の値は、szProductCodeOrPatchCode の値の解釈とクリアするソースの種類を決定します。このパラメーターは、次の MSISOURCETYPE_* 定数のいずれか 1 つと、次の MSICODE_* 定数のいずれか 1 つを組み合わせたものである必要があります。

フラグ 意味
MSISOURCETYPE_NETWORK
ソースはネットワーク型です。
MSISOURCETYPE_URL
ソースは URL 型です。
MSICODE_PRODUCT
szProductCodeOrPatchCode は製品コードです。
MSICODE_PATCH
szProductCodeOrPatchCode はパッチコードです。
szSourceLPCWSTRin削除するソース。このパラメーターには、ファイル名を含まないパスのみを指定することが想定されています。 ファイル名はすでに "PackageName" として登録されており、MsiSourceListSetInfo を通じて操作できます。この引数は必須です。

戻り値の型: DWORD

公式ドキュメント

指定したコンテキストにおいて、製品またはパッチの既存のソースを削除します。(Unicode)

戻り値

MsiSourceListClearSource 関数は次の値を返します。

意味
ERROR_ACCESS_DENIED
ユーザーにソースを削除する権限がありません。製品またはパッチが見つかったかどうかは示しません。
ERROR_BAD_CONFIGURATION
構成データが破損しています。
ERROR_INSTALL_SERVICE_FAILURE
Windows Installer サービスにアクセスできませんでした。
ERROR_INVALID_PARAMETER
無効なパラメーターが関数に渡されました。
ERROR_SUCCESS
ソースが削除されたか、見つかりませんでした。
ERROR_UNKNOWN_PATCH
指定されたパッチが不明です。
ERROR_UNKNOWN_PRODUCT
指定された製品が不明です。
ERROR_FUNCTION_FAILED
予期しない内部エラーが発生しました。

解説(Remarks)

管理者は、マシンコンテキストまたは自身のユーザー単位コンテキスト(管理対象・非管理対象を問わず)に存在する製品またはパッチインスタンスのインストールを変更できます。また、任意のユーザーのユーザー単位の管理対象コンテキストに存在する製品またはパッチインスタンスのインストールも変更できます。管理者は、他のユーザーのユーザー単位の非管理対象コンテキストに存在する、そのユーザーの製品またはパッチインスタンスのインストールを変更することはできません。

非管理者は、他のユーザーのユーザー単位コンテキスト(管理対象・非管理対象を問わず)に存在する製品またはパッチインスタンスのインストールを変更できません。自身のユーザー単位の非管理対象コンテキストに存在する製品またはパッチインスタンスのインストールは変更できます。マシンコンテキストまたは自身のユーザー単位の管理対象コンテキストに存在する製品またはパッチインスタンスのインストールは、製品またはパッチソースの参照が許可されている場合に限り変更できます。ユーザーがソースを参照できるようにするには、ポリシーを設定します。詳細については、DisableBrowseAllowLockdownBrowse、および AlwaysInstallElevated の各ポリシーを参照してください。

メモ

msi.h ヘッダーは MsiSourceListClearSource を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスの使用を、エンコーディング非依存でないコードと混在させると、不整合が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

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

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListClearSourceW = msi.NewProc("MsiSourceListClearSourceW")
)

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

extern "msi" fn MsiSourceListClearSourceW(
    szProductCodeOrPatchCode: [*c]const u16, // LPCWSTR
    szUserSid: [*c]const u16, // LPCWSTR optional
    dwContext: i32, // MSIINSTALLCONTEXT
    dwOptions: u32, // DWORD
    szSource: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) u32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc MsiSourceListClearSourceW(
    szProductCodeOrPatchCode: WideCString,  # LPCWSTR
    szUserSid: WideCString,  # LPCWSTR optional
    dwContext: int32,  # MSIINSTALLCONTEXT
    dwOptions: uint32,  # DWORD
    szSource: WideCString  # LPCWSTR
): uint32 {.importc: "MsiSourceListClearSourceW", stdcall, dynlib: "msi.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "msi");
extern(Windows)
uint MsiSourceListClearSourceW(
    const(wchar)* szProductCodeOrPatchCode,   // LPCWSTR
    const(wchar)* szUserSid,   // LPCWSTR optional
    int dwContext,   // MSIINSTALLCONTEXT
    uint dwOptions,   // DWORD
    const(wchar)* szSource   // LPCWSTR
);
ccall((:MsiSourceListClearSourceW, "msi.dll"), stdcall, UInt32,
      (Cwstring, Cwstring, Int32, UInt32, Cwstring),
      szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource)
# szProductCodeOrPatchCode : LPCWSTR -> Cwstring
# szUserSid : LPCWSTR optional -> Cwstring
# dwContext : MSIINSTALLCONTEXT -> Int32
# dwOptions : DWORD -> UInt32
# szSource : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiSourceListClearSourceW(
    const uint16_t* szProductCodeOrPatchCode,
    const uint16_t* szUserSid,
    int32_t dwContext,
    uint32_t dwOptions,
    const uint16_t* szSource);
]]
local msi = ffi.load("msi")
-- msi.MsiSourceListClearSourceW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource)
-- szProductCodeOrPatchCode : LPCWSTR
-- szUserSid : LPCWSTR optional
-- dwContext : MSIINSTALLCONTEXT
-- dwOptions : DWORD
-- szSource : LPCWSTR
-- 構造体/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 MsiSourceListClearSourceW = lib.func('__stdcall', 'MsiSourceListClearSourceW', 'uint32_t', ['str16', 'str16', 'int32_t', 'uint32_t', 'str16']);
// MsiSourceListClearSourceW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource)
// szProductCodeOrPatchCode : LPCWSTR -> 'str16'
// szUserSid : LPCWSTR optional -> 'str16'
// dwContext : MSIINSTALLCONTEXT -> 'int32_t'
// dwOptions : DWORD -> 'uint32_t'
// szSource : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msi.dll", {
  MsiSourceListClearSourceW: { parameters: ["buffer", "buffer", "i32", "u32", "buffer"], result: "u32" },
});
// lib.symbols.MsiSourceListClearSourceW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource)
// szProductCodeOrPatchCode : LPCWSTR -> "buffer"
// szUserSid : LPCWSTR optional -> "buffer"
// dwContext : MSIINSTALLCONTEXT -> "i32"
// dwOptions : DWORD -> "u32"
// szSource : LPCWSTR -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiSourceListClearSourceW(
    const uint16_t* szProductCodeOrPatchCode,
    const uint16_t* szUserSid,
    int32_t dwContext,
    uint32_t dwOptions,
    const uint16_t* szSource);
C, "msi.dll");
// $ffi->MsiSourceListClearSourceW(szProductCodeOrPatchCode, szUserSid, dwContext, dwOptions, szSource);
// szProductCodeOrPatchCode : LPCWSTR
// szUserSid : LPCWSTR optional
// dwContext : MSIINSTALLCONTEXT
// dwOptions : DWORD
// szSource : LPCWSTR
// 構造体/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 MsiSourceListClearSourceW(
        WString szProductCodeOrPatchCode,   // LPCWSTR
        WString szUserSid,   // LPCWSTR optional
        int dwContext,   // MSIINSTALLCONTEXT
        int dwOptions,   // DWORD
        WString szSource   // LPCWSTR
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("msi")]
lib Libmsi
  fun MsiSourceListClearSourceW = MsiSourceListClearSourceW(
    szProductCodeOrPatchCode : UInt16*,   # LPCWSTR
    szUserSid : UInt16*,   # LPCWSTR optional
    dwContext : Int32,   # MSIINSTALLCONTEXT
    dwOptions : UInt32,   # DWORD
    szSource : UInt16*   # LPCWSTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MsiSourceListClearSourceWNative = Uint32 Function(Pointer<Utf16>, Pointer<Utf16>, Int32, Uint32, Pointer<Utf16>);
typedef MsiSourceListClearSourceWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, int, Pointer<Utf16>);
final MsiSourceListClearSourceW = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiSourceListClearSourceWNative, MsiSourceListClearSourceWDart>('MsiSourceListClearSourceW');
// szProductCodeOrPatchCode : LPCWSTR -> Pointer<Utf16>
// szUserSid : LPCWSTR optional -> Pointer<Utf16>
// dwContext : MSIINSTALLCONTEXT -> Int32
// dwOptions : DWORD -> Uint32
// szSource : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiSourceListClearSourceW(
  szProductCodeOrPatchCode: PWideChar;   // LPCWSTR
  szUserSid: PWideChar;   // LPCWSTR optional
  dwContext: Integer;   // MSIINSTALLCONTEXT
  dwOptions: DWORD;   // DWORD
  szSource: PWideChar   // LPCWSTR
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListClearSourceW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiSourceListClearSourceW"
  c_MsiSourceListClearSourceW :: CWString -> CWString -> Int32 -> Word32 -> CWString -> IO Word32
-- szProductCodeOrPatchCode : LPCWSTR -> CWString
-- szUserSid : LPCWSTR optional -> CWString
-- dwContext : MSIINSTALLCONTEXT -> Int32
-- dwOptions : DWORD -> Word32
-- szSource : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msisourcelistclearsourcew =
  foreign "MsiSourceListClearSourceW"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> uint32_t @-> (ptr uint16_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) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)

(cffi:defcfun ("MsiSourceListClearSourceW" msi-source-list-clear-source-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
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiSourceListClearSourceW = Win32::API::More->new('msi',
    'DWORD MsiSourceListClearSourceW(LPCWSTR szProductCodeOrPatchCode, LPCWSTR szUserSid, int dwContext, DWORD dwOptions, LPCWSTR szSource)');
# my $ret = $MsiSourceListClearSourceW->Call($szProductCodeOrPatchCode, $szUserSid, $dwContext, $dwOptions, $szSource);
# szProductCodeOrPatchCode : LPCWSTR -> LPCWSTR
# szUserSid : LPCWSTR optional -> LPCWSTR
# dwContext : MSIINSTALLCONTEXT -> int
# dwOptions : DWORD -> DWORD
# szSource : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
公式の関連項目
使用する型