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

MsiEvaluateConditionA

関数
条件式を評価して真偽などの状態を返す(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

MSICONDITION MsiEvaluateConditionA(
    MSIHANDLE hInstall,
    LPCSTR szCondition
);

パラメーター

名前方向説明
hInstallMSIHANDLEinDLL カスタムアクションに提供されたインストールのハンドル、または MsiOpenPackageMsiOpenPackageExMsiOpenProduct を通じて取得したハンドルです。
szConditionLPCSTRin条件式を指定します。このパラメーターは NULL にできません。条件式の構文については、 Conditional Statement Syntax を参照してください。

戻り値の型: MSICONDITION

公式ドキュメント

MsiEvaluateCondition 関数は、プロパティ名と値を含む条件式を評価します。(ANSI)

戻り値

この関数は MSICONDITION を返します。

解説(Remarks)

次の表は、 MsiEvaluateCondition 関数で使用される機能およびコンポーネントの状態値を示しています。これらの状態は、 MsiSetInstallLevel が直接、または CostFinalize アクション によって呼び出されるまで設定されません。したがって、状態のチェックが有用なのは、一般にアクションシーケンステーブル内の条件式に限られます。

意味
INSTALLSTATE_ABSENT 機能またはコンポーネントが存在しません。
INSTALLSTATE_LOCAL 機能またはコンポーネントがローカルコンピューター上にあります。
INSTALLSTATE_SOURCE 機能またはコンポーネントがソースから実行されます。
(null 値) 機能またはコンポーネントに対して実行されるアクションはありません。
メモ

msiquery.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして MsiEvaluateCondition を定義します。エンコーディング中立のエイリアスの使用と、エンコーディング中立でないコードを混在させると、不一致が生じてコンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、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>

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

MsiEvaluateConditionA = ctypes.windll.msi.MsiEvaluateConditionA
MsiEvaluateConditionA.restype = ctypes.c_int
MsiEvaluateConditionA.argtypes = [
    wintypes.DWORD,  # hInstall : MSIHANDLE
    wintypes.LPCSTR,  # szCondition : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiEvaluateConditionA = msi.NewProc("MsiEvaluateConditionA")
)

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

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

typedef MsiEvaluateConditionANative = Int32 Function(Uint32, Pointer<Utf8>);
typedef MsiEvaluateConditionADart = int Function(int, Pointer<Utf8>);
final MsiEvaluateConditionA = DynamicLibrary.open('msi.dll')
    .lookupFunction<MsiEvaluateConditionANative, MsiEvaluateConditionADart>('MsiEvaluateConditionA');
// hInstall : MSIHANDLE -> Uint32
// szCondition : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MsiEvaluateConditionA(
  hInstall: DWORD;   // MSIHANDLE
  szCondition: PAnsiChar   // LPCSTR
): Integer; stdcall;
  external 'msi.dll' name 'MsiEvaluateConditionA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MsiEvaluateConditionA"
  c_MsiEvaluateConditionA :: Word32 -> CString -> IO Int32
-- hInstall : MSIHANDLE -> Word32
-- szCondition : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let msievaluateconditiona =
  foreign "MsiEvaluateConditionA"
    (uint32_t @-> string @-> returning int32_t)
(* hInstall : MSIHANDLE -> uint32_t *)
(* szCondition : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library msi (t "msi.dll"))
(cffi:use-foreign-library msi)

(cffi:defcfun ("MsiEvaluateConditionA" msi-evaluate-condition-a :convention :stdcall) :int32
  (h-install :uint32)   ; MSIHANDLE
  (sz-condition :string))   ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MsiEvaluateConditionA = Win32::API::More->new('msi',
    'int MsiEvaluateConditionA(DWORD hInstall, LPCSTR szCondition)');
# my $ret = $MsiEvaluateConditionA->Call($hInstall, $szCondition);
# hInstall : MSIHANDLE -> DWORD
# szCondition : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
使用する型