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

MsiSourceListForceResolutionA

関数
次回ソース使用時にソースを再解決するよう強制する。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

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

パラメーター

名前方向説明
szProductLPCSTRin変更する製品の ProductCode です。
szUserNameLPCSTRinoptional

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

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

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

戻り値の型: DWORD

公式ドキュメント

MsiSourceListForceResolution 関数は、次回ソースが必要になったときに、有効な製品ソースをソースリストから検索するようインストーラーに強制します。(ANSI)

戻り値

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

意味
ERROR_ACCESS_DENIED
呼び出し元が、この製品の解決を強制するための十分なアクセス権を持っていません。
ERROR_BAD_CONFIGURATION
構成データが破損しています。
ERROR_BAD_USER_NAME
指定されたユーザーは有効なユーザーではありません。
ERROR_FUNCTION_FAILED
関数を完了できませんでした。
ERROR_INSTALL_SERVICE_FAILURE
インストールサービスにアクセスできませんでした。
ERROR_INVALID_PARAMETER
無効なパラメーターが関数に渡されました。
ERROR_SUCCESS
関数は成功しました。
ERROR_UNKNOWN_PRODUCT
指定された製品は不明です。

解説(Remarks)

管理者は、コンピューター単位のインストール、自分自身のユーザー単位の非管理対象インストール、および任意のユーザーのユーザー単位の管理対象インストールを変更できます。管理者以外のユーザーは、コンピューター単位のインストールと、自分自身の(管理対象または非管理対象の)ユーザー単位のインストールのみを変更できます。

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

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

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

メモ

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

出典・ライセンス: 上記「公式ドキュメント」の内容は 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 MsiSourceListForceResolutionA(
    LPCSTR szProduct,
    LPCSTR szUserName,   // optional
    DWORD dwReserved   // optional
);
[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint MsiSourceListForceResolutionA(
    [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 MsiSourceListForceResolutionA(
    <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 MsiSourceListForceResolutionA 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

MsiSourceListForceResolutionA = ctypes.windll.msi.MsiSourceListForceResolutionA
MsiSourceListForceResolutionA.restype = wintypes.DWORD
MsiSourceListForceResolutionA.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')
MsiSourceListForceResolutionA = Fiddle::Function.new(
  lib['MsiSourceListForceResolutionA'],
  [
    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 MsiSourceListForceResolutionA(
        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 MsiSourceListForceResolutionA([MarshalAs(UnmanagedType.LPStr)] string szProduct, [MarshalAs(UnmanagedType.LPStr)] string szUserName, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiSourceListForceResolutionA' -Namespace Win32 -PassThru
# $api::MsiSourceListForceResolutionA(szProduct, szUserName, dwReserved)
#uselib "msi.dll"
#func global MsiSourceListForceResolutionA "MsiSourceListForceResolutionA" sptr, sptr, sptr
; MsiSourceListForceResolutionA szProduct, szUserName, dwReserved   ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; szUserName : LPCSTR optional -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiSourceListForceResolutionA "MsiSourceListForceResolutionA" str, str, int
; res = MsiSourceListForceResolutionA(szProduct, szUserName, dwReserved)
; szProduct : LPCSTR -> "str"
; szUserName : LPCSTR optional -> "str"
; dwReserved : DWORD optional -> "int"
; DWORD MsiSourceListForceResolutionA(LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved)
#uselib "msi.dll"
#cfunc global MsiSourceListForceResolutionA "MsiSourceListForceResolutionA" str, str, int
; res = MsiSourceListForceResolutionA(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")
	procMsiSourceListForceResolutionA = msi.NewProc("MsiSourceListForceResolutionA")
)

// szProduct (LPCSTR), szUserName (LPCSTR optional), dwReserved (DWORD optional)
r1, _, err := procMsiSourceListForceResolutionA.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 MsiSourceListForceResolutionA(
  szProduct: PAnsiChar;   // LPCSTR
  szUserName: PAnsiChar;   // LPCSTR optional
  dwReserved: DWORD   // DWORD optional
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListForceResolutionA';
result := DllCall("msi\MsiSourceListForceResolutionA"
    , "AStr", szProduct   ; LPCSTR
    , "AStr", szUserName   ; LPCSTR optional
    , "UInt", dwReserved   ; DWORD optional
    , "UInt")   ; return: DWORD
●MsiSourceListForceResolutionA(szProduct, szUserName, dwReserved) = DLL("msi.dll", "dword MsiSourceListForceResolutionA(char*, char*, dword)")
# 呼び出し: MsiSourceListForceResolutionA(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 MsiSourceListForceResolutionA(
    szProduct: [*c]const u8, // LPCSTR
    szUserName: [*c]const u8, // LPCSTR optional
    dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) u32;
proc MsiSourceListForceResolutionA(
    szProduct: cstring,  # LPCSTR
    szUserName: cstring,  # LPCSTR optional
    dwReserved: uint32  # DWORD optional
): uint32 {.importc: "MsiSourceListForceResolutionA", stdcall, dynlib: "msi.dll".}
pragma(lib, "msi");
extern(Windows)
uint MsiSourceListForceResolutionA(
    const(char)* szProduct,   // LPCSTR
    const(char)* szUserName,   // LPCSTR optional
    uint dwReserved   // DWORD optional
);
ccall((:MsiSourceListForceResolutionA, "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 MsiSourceListForceResolutionA(
    const char* szProduct,
    const char* szUserName,
    uint32_t dwReserved);
]]
local msi = ffi.load("msi")
-- msi.MsiSourceListForceResolutionA(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 MsiSourceListForceResolutionA = lib.func('__stdcall', 'MsiSourceListForceResolutionA', 'uint32_t', ['str', 'str', 'uint32_t']);
// MsiSourceListForceResolutionA(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", {
  MsiSourceListForceResolutionA: { parameters: ["buffer", "buffer", "u32"], result: "u32" },
});
// lib.symbols.MsiSourceListForceResolutionA(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 MsiSourceListForceResolutionA(
    const char* szProduct,
    const char* szUserName,
    uint32_t dwReserved);
C, "msi.dll");
// $ffi->MsiSourceListForceResolutionA(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 MsiSourceListForceResolutionA(
        String szProduct,   // LPCSTR
        String szUserName,   // LPCSTR optional
        int dwReserved   // DWORD optional
    );
}
@[Link("msi")]
lib Libmsi
  fun MsiSourceListForceResolutionA = MsiSourceListForceResolutionA(
    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 MsiSourceListForceResolutionANative = Uint32 Function(Pointer<Utf8>, Pointer<Utf8>, Uint32);
typedef MsiSourceListForceResolutionADart = int Function(Pointer<Utf8>, Pointer<Utf8>, int);
final MsiSourceListForceResolutionA = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiSourceListForceResolutionANative, MsiSourceListForceResolutionADart>('MsiSourceListForceResolutionA');
// szProduct : LPCSTR -> Pointer<Utf8>
// szUserName : LPCSTR optional -> Pointer<Utf8>
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiSourceListForceResolutionA(
  szProduct: PAnsiChar;   // LPCSTR
  szUserName: PAnsiChar;   // LPCSTR optional
  dwReserved: DWORD   // DWORD optional
): DWORD; stdcall;
  external 'msi.dll' name 'MsiSourceListForceResolutionA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiSourceListForceResolutionA"
  c_MsiSourceListForceResolutionA :: 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 msisourcelistforceresolutiona =
  foreign "MsiSourceListForceResolutionA"
    (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 ("MsiSourceListForceResolutionA" msi-source-list-force-resolution-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 $MsiSourceListForceResolutionA = Win32::API::More->new('msi',
    'DWORD MsiSourceListForceResolutionA(LPCSTR szProduct, LPCSTR szUserName, DWORD dwReserved)');
# my $ret = $MsiSourceListForceResolutionA->Call($szProduct, $szUserName, $dwReserved);
# szProduct : LPCSTR -> LPCSTR
# szUserName : LPCSTR optional -> LPCSTR
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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