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