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

MsiQueryFeatureStateA

関数
製品機能のインストール状態を問い合わせる(ANSI版)。
DLLmsi.dll文字セットANSI (-A)呼出規約winapi対応OSwindows8.0

シグネチャ

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

INSTALLSTATE MsiQueryFeatureStateA(
    LPCSTR szProduct,
    LPCSTR szFeature
);

パラメーター

名前方向
szProductLPCSTRin
szFeatureLPCSTRin

戻り値の型: INSTALLSTATE

各言語での呼び出し定義

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

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

MsiQueryFeatureStateA = ctypes.windll.msi.MsiQueryFeatureStateA
MsiQueryFeatureStateA.restype = ctypes.c_int
MsiQueryFeatureStateA.argtypes = [
    wintypes.LPCSTR,  # szProduct : LPCSTR
    wintypes.LPCSTR,  # szFeature : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiQueryFeatureStateA = Fiddle::Function.new(
  lib['MsiQueryFeatureStateA'],
  [
    Fiddle::TYPE_VOIDP,  # szProduct : LPCSTR
    Fiddle::TYPE_VOIDP,  # szFeature : LPCSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "msi")]
extern "system" {
    fn MsiQueryFeatureStateA(
        szProduct: *const u8,  // LPCSTR
        szFeature: *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 MsiQueryFeatureStateA([MarshalAs(UnmanagedType.LPStr)] string szProduct, [MarshalAs(UnmanagedType.LPStr)] string szFeature);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiQueryFeatureStateA' -Namespace Win32 -PassThru
# $api::MsiQueryFeatureStateA(szProduct, szFeature)
#uselib "msi.dll"
#func global MsiQueryFeatureStateA "MsiQueryFeatureStateA" sptr, sptr
; MsiQueryFeatureStateA szProduct, szFeature   ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; szFeature : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiQueryFeatureStateA "MsiQueryFeatureStateA" str, str
; res = MsiQueryFeatureStateA(szProduct, szFeature)
; szProduct : LPCSTR -> "str"
; szFeature : LPCSTR -> "str"
; INSTALLSTATE MsiQueryFeatureStateA(LPCSTR szProduct, LPCSTR szFeature)
#uselib "msi.dll"
#cfunc global MsiQueryFeatureStateA "MsiQueryFeatureStateA" str, str
; res = MsiQueryFeatureStateA(szProduct, szFeature)
; szProduct : LPCSTR -> "str"
; szFeature : LPCSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiQueryFeatureStateA = msi.NewProc("MsiQueryFeatureStateA")
)

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