ホーム › System.ApplicationInstallationAndServicing › MsiQueryFeatureStateW
MsiQueryFeatureStateW
関数製品機能のインストール状態を問い合わせる(Unicode版)。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
INSTALLSTATE MsiQueryFeatureStateW(
LPCWSTR szProduct,
LPCWSTR szFeature
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szProduct | LPCWSTR | in |
| szFeature | LPCWSTR | in |
戻り値の型: INSTALLSTATE
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
INSTALLSTATE MsiQueryFeatureStateW(
LPCWSTR szProduct,
LPCWSTR szFeature
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int MsiQueryFeatureStateW(
[MarshalAs(UnmanagedType.LPWStr)] string szProduct, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szFeature // LPCWSTR
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiQueryFeatureStateW(
<MarshalAs(UnmanagedType.LPWStr)> szProduct As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szFeature As String ' LPCWSTR
) As Integer
End Function' szProduct : LPCWSTR
' szFeature : LPCWSTR
Declare PtrSafe Function MsiQueryFeatureStateW Lib "msi" ( _
ByVal szProduct As LongPtr, _
ByVal szFeature As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
MsiQueryFeatureStateW = ctypes.windll.msi.MsiQueryFeatureStateW
MsiQueryFeatureStateW.restype = ctypes.c_int
MsiQueryFeatureStateW.argtypes = [
wintypes.LPCWSTR, # szProduct : LPCWSTR
wintypes.LPCWSTR, # szFeature : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiQueryFeatureStateW = Fiddle::Function.new(
lib['MsiQueryFeatureStateW'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCWSTR
Fiddle::TYPE_VOIDP, # szFeature : LPCWSTR
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiQueryFeatureStateW(
szProduct: *const u16, // LPCWSTR
szFeature: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern int MsiQueryFeatureStateW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, [MarshalAs(UnmanagedType.LPWStr)] string szFeature);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiQueryFeatureStateW' -Namespace Win32 -PassThru
# $api::MsiQueryFeatureStateW(szProduct, szFeature)#uselib "msi.dll"
#func global MsiQueryFeatureStateW "MsiQueryFeatureStateW" wptr, wptr
; MsiQueryFeatureStateW szProduct, szFeature ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; szFeature : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiQueryFeatureStateW "MsiQueryFeatureStateW" wstr, wstr
; res = MsiQueryFeatureStateW(szProduct, szFeature)
; szProduct : LPCWSTR -> "wstr"
; szFeature : LPCWSTR -> "wstr"; INSTALLSTATE MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
#uselib "msi.dll"
#cfunc global MsiQueryFeatureStateW "MsiQueryFeatureStateW" wstr, wstr
; res = MsiQueryFeatureStateW(szProduct, szFeature)
; szProduct : LPCWSTR -> "wstr"
; szFeature : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiQueryFeatureStateW = msi.NewProc("MsiQueryFeatureStateW")
)
// szProduct (LPCWSTR), szFeature (LPCWSTR)
r1, _, err := procMsiQueryFeatureStateW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFeature))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INSTALLSTATEfunction MsiQueryFeatureStateW(
szProduct: PWideChar; // LPCWSTR
szFeature: PWideChar // LPCWSTR
): Integer; stdcall;
external 'msi.dll' name 'MsiQueryFeatureStateW';result := DllCall("msi\MsiQueryFeatureStateW"
, "WStr", szProduct ; LPCWSTR
, "WStr", szFeature ; LPCWSTR
, "Int") ; return: INSTALLSTATE●MsiQueryFeatureStateW(szProduct, szFeature) = DLL("msi.dll", "int MsiQueryFeatureStateW(char*, char*)")
# 呼び出し: MsiQueryFeatureStateW(szProduct, szFeature)
# szProduct : LPCWSTR -> "char*"
# szFeature : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。