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

MsiSourceListClearAllA

関数
製品のネットワークソースリストをすべて削除する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiSourceListClearAllA(
    LPCSTR szProduct,
    LPCSTR szUserName,   // optional
    DWORD dwReserved   // optional
);

パラメーター

名前方向説明
szProductLPCSTRin変更対象の製品の ProductCode
szUserNameLPCSTRinoptional

ユーザー単位インストールのユーザー名。ユーザー名は常に DOMAIN\USERNAME 形式(ローカルユーザーの場合は MACHINENAME\USERNAME)で指定する必要があります。

コンピューター単位インストールの場合は、空文字列または NULL を指定します。

dwReservedDWORDoptional将来の使用のために予約されています。この値は 0 に設定する必要があります。

戻り値の型: DWORD

公式ドキュメント

MsiSourceListClearAll 関数は、指定したコンテキストにおけるパッチまたは製品のソースリストから、すべてのネットワークソースを削除します。詳細については、「Source Resiliency」を参照してください。(ANSI)

戻り値

MsiSourceListClearAll 関数は、以下の値を返します。

意味
ERROR_ACCESS_DENIED
ユーザーにこの製品のソースリストをクリアする権限がありません。
ERROR_BAD_CONFIGURATION
構成データが破損しています。
ERROR_BAD_USERNAME
ユーザー名を解決できませんでした。
ERROR_FUNCTION_FAILED
関数が失敗しました。
ERROR_INSTALL_SERVICE_FAILURE
インストーラーサービスにアクセスできませんでした。
ERROR_INVALID_PARAMETER
関数に無効なパラメーターが渡されました。
ERROR_SUCCESS
関数が成功しました。
ERROR_UNKNOWN_PRODUCT
指定された製品は不明です。

解説(Remarks)

管理者は、コンピューター単位インストール、自身の非管理対象のユーザー単位インストール、および任意のユーザーの管理対象のユーザー単位インストールを変更できます。非管理者は、コンピューター単位インストールと、自身の(管理対象または非管理対象の)ユーザー単位インストールのみを変更できます。ポリシーを設定することで、ユーザーがソースを参照できるようにすることが可能です。詳細については、DisableBrowseAllowLockdownBrowse、および AlwaysInstallElevated の各ポリシーを参照してください。

ネットワークソースが製品の現在のソースである場合、この関数を実行すると、次回ソースが必要になったときにインストーラーが有効なソースをソースリストから検索するようになります。現在のソースがメディアまたは URL ソースである場合、この呼び出し後も有効なままであり、MsiSourceListForceResolution も併せて呼び出さない限りソースリストは検索されません。

ユーザー名が空文字列または NULL の場合、この関数は製品のコンピューター単位インストールに対して動作します。この場合、製品がユーザー単位でのみインストールされていると、関数は ERROR_UNKNOWN_PRODUCT を返します。

ユーザー名が空文字列でも NULL でもない場合は、インストールを変更する対象製品のユーザー名を指定します。ユーザー名が現在のユーザー名である場合、関数はまず製品の非管理対象インストールの変更を試みます。製品の非管理対象インストールが見つからない場合、関数は次に管理対象のユーザー単位インストールの変更を試みます。製品の管理対象または非管理対象のユーザー単位インストールが見つからない場合、製品がコンピューター単位でインストールされていても、関数は ERROR_UNKNOWN_PRODUCT を返します。

この関数は、現在のユーザー以外のユーザーの非管理対象インストールを変更することはできません。ユーザー名が空文字列でも NULL でもなく、かつ現在のユーザーでもない場合、関数は指定されたユーザーの製品の管理対象のユーザー単位インストールのみを確認します。指定されたユーザーに対して製品が管理対象のユーザー単位としてインストールされていない場合、製品がコンピューター単位でインストールされていても、関数は ERROR_UNKNOWN_PRODUCT を返します。

メモ

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

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

各言語での呼び出し定義

// msi.dll  (ANSI / -A)
#include <windows.h>

DWORD MsiSourceListClearAllA(
    LPCSTR szProduct,
    LPCSTR szUserName,   // optional
    DWORD dwReserved   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiSourceListClearAllA(
    [MarshalAs(UnmanagedType.LPStr)] string szProduct,   // LPCSTR
    [MarshalAs(UnmanagedType.LPStr)] string szUserName,   // LPCSTR optional
    uint dwReserved   // DWORD optional
);
<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiSourceListClearAllA(
    <MarshalAs(UnmanagedType.LPStr)> szProduct As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> szUserName As String,   ' LPCSTR optional
    dwReserved As UInteger   ' DWORD optional
) As UInteger
End Function
' szProduct : LPCSTR
' szUserName : LPCSTR optional
' dwReserved : DWORD optional
Declare PtrSafe Function MsiSourceListClearAllA Lib "msi" ( _
    ByVal szProduct As String, _
    ByVal szUserName As String, _
    ByVal dwReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MsiSourceListClearAllA = ctypes.windll.msi.MsiSourceListClearAllA
MsiSourceListClearAllA.restype = wintypes.DWORD
MsiSourceListClearAllA.argtypes = [
    wintypes.LPCSTR,  # szProduct : LPCSTR
    wintypes.LPCSTR,  # szUserName : LPCSTR optional
    wintypes.DWORD,  # dwReserved : DWORD optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiSourceListClearAllA = Fiddle::Function.new(
  lib['MsiSourceListClearAllA'],
  [
    Fiddle::TYPE_VOIDP,  # szProduct : LPCSTR
    Fiddle::TYPE_VOIDP,  # szUserName : LPCSTR optional
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiSourceListClearAllA(
        szProduct: *const u8,  // LPCSTR
        szUserName: *const u8,  // LPCSTR optional
        dwReserved: u32  // DWORD optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Ansi)]
public static extern uint MsiSourceListClearAllA([MarshalAs(UnmanagedType.LPStr)] string szProduct, [MarshalAs(UnmanagedType.LPStr)] string szUserName, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListClearAllA' -Namespace Win32 -PassThru
# $api::MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
#uselib "msi.dll"
#func global MsiSourceListClearAllA "MsiSourceListClearAllA" sptr, sptr, sptr
; MsiSourceListClearAllA szProduct, szUserName, dwReserved   ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; szUserName : LPCSTR optional -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiSourceListClearAllA "MsiSourceListClearAllA" str, str, int
; res = MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
; szProduct : LPCSTR -> "str"
; szUserName : LPCSTR optional -> "str"
; dwReserved : DWORD optional -> "int"
; DWORD MsiSourceListClearAllA(LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved)
#uselib "msi.dll"
#cfunc global MsiSourceListClearAllA "MsiSourceListClearAllA" str, str, int
; res = MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
; szProduct : LPCSTR -> "str"
; szUserName : LPCSTR optional -> "str"
; dwReserved : DWORD optional -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiSourceListClearAllA = msi.NewProc("MsiSourceListClearAllA")
)

// szProduct (LPCSTR), szUserName (LPCSTR optional), dwReserved (DWORD optional)
r1, _, err := procMsiSourceListClearAllA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szProduct))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(szUserName))),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MsiSourceListClearAllA(
  szProduct: PAnsiChar;   // LPCSTR
  szUserName: PAnsiChar;   // LPCSTR optional
  dwReserved: DWORD   // DWORD optional
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListClearAllA';
result := DllCall("msi\MsiSourceListClearAllA"
    , "AStr", szProduct   ; LPCSTR
    , "AStr", szUserName   ; LPCSTR optional
    , "UInt", dwReserved   ; DWORD optional
    , "UInt")   ; return: DWORD
●MsiSourceListClearAllA(szProduct, szUserName, dwReserved) = DLL("msi.dll", "dword MsiSourceListClearAllA(char*, char*, dword)")
# 呼び出し: MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
# szProduct : LPCSTR -> "char*"
# szUserName : LPCSTR optional -> "char*"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "msi" fn MsiSourceListClearAllA(
    szProduct: [*c]const u8, // LPCSTR
    szUserName: [*c]const u8, // LPCSTR optional
    dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) u32;
proc MsiSourceListClearAllA(
    szProduct: cstring,  # LPCSTR
    szUserName: cstring,  # LPCSTR optional
    dwReserved: uint32  # DWORD optional
): uint32 {.importc: "MsiSourceListClearAllA", stdcall, dynlib: "msi.dll".}
pragma(lib, "msi");
extern(Windows)
uint MsiSourceListClearAllA(
    const(char)* szProduct,   // LPCSTR
    const(char)* szUserName,   // LPCSTR optional
    uint dwReserved   // DWORD optional
);
ccall((:MsiSourceListClearAllA, "msi.dll"), stdcall, UInt32,
      (Cstring, Cstring, UInt32),
      szProduct, szUserName, dwReserved)
# szProduct : LPCSTR -> Cstring
# szUserName : LPCSTR optional -> Cstring
# dwReserved : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MsiSourceListClearAllA(
    const char* szProduct,
    const char* szUserName,
    uint32_t dwReserved);
]]
local msi = ffi.load("msi")
-- msi.MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
-- szProduct : LPCSTR
-- szUserName : LPCSTR optional
-- dwReserved : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('msi.dll');
const MsiSourceListClearAllA = lib.func('__stdcall', 'MsiSourceListClearAllA', 'uint32_t', ['str', 'str', 'uint32_t']);
// MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
// szProduct : LPCSTR -> 'str'
// szUserName : LPCSTR optional -> 'str'
// dwReserved : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("msi.dll", {
  MsiSourceListClearAllA: { parameters: ["buffer", "buffer", "u32"], result: "u32" },
});
// lib.symbols.MsiSourceListClearAllA(szProduct, szUserName, dwReserved)
// szProduct : LPCSTR -> "buffer"
// szUserName : LPCSTR optional -> "buffer"
// dwReserved : DWORD optional -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MsiSourceListClearAllA(
    const char* szProduct,
    const char* szUserName,
    uint32_t dwReserved);
C, "msi.dll");
// $ffi->MsiSourceListClearAllA(szProduct, szUserName, dwReserved);
// szProduct : LPCSTR
// szUserName : LPCSTR optional
// dwReserved : DWORD optional
// 構造体/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 MsiSourceListClearAllA(
        String szProduct,   // LPCSTR
        String szUserName,   // LPCSTR optional
        int dwReserved   // DWORD optional
    );
}
@[Link("msi")]
lib Libmsi
  fun MsiSourceListClearAllA = MsiSourceListClearAllA(
    szProduct : UInt8*,   # LPCSTR
    szUserName : UInt8*,   # LPCSTR optional
    dwReserved : UInt32   # DWORD optional
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MsiSourceListClearAllANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Uint32);
typedef MsiSourceListClearAllADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int);
final MsiSourceListClearAllA = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiSourceListClearAllANative, MsiSourceListClearAllADart>('MsiSourceListClearAllA');
// szProduct : LPCSTR -> Pointer<Utf8>
// szUserName : LPCSTR optional -> Pointer<Utf8>
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiSourceListClearAllA(
  szProduct: PAnsiChar;   // LPCSTR
  szUserName: PAnsiChar;   // LPCSTR optional
  dwReserved: DWORD   // DWORD optional
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListClearAllA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiSourceListClearAllA"
  c_MsiSourceListClearAllA :: CString -> CString -> Word32 -> IO Word32
-- szProduct : LPCSTR -> CString
-- szUserName : LPCSTR optional -> CString
-- dwReserved : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msisourcelistclearalla =
  foreign "MsiSourceListClearAllA"
    (string @-> string @-> uint32_t @-> returning uint32_t)
(* szProduct : LPCSTR -> string *)
(* szUserName : LPCSTR optional -> string *)
(* dwReserved : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)

(cffi:defcfun ("MsiSourceListClearAllA" msi-source-list-clear-all-a :convention :stdcall) :uint32
  (sz-product :string)   ; LPCSTR
  (sz-user-name :string)   ; LPCSTR optional
  (dw-reserved :uint32))   ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiSourceListClearAllA = Win32::API::More->new('msi',
    'DWORD MsiSourceListClearAllA(LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved)');
# my $ret = $MsiSourceListClearAllA->Call($szProduct, $szUserName, $dwReserved);
# szProduct : LPCSTR -> LPCSTR
# szUserName : LPCSTR optional -> LPCSTR
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
類似 API
公式の関連項目