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