ホーム › System.ApplicationInstallationAndServicing › MsiGetFeatureUsageW
MsiGetFeatureUsageW
関数機能の使用回数と最終使用日を取得する(Unicode版)。
シグネチャ
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiGetFeatureUsageW(
LPCWSTR szProduct,
LPCWSTR szFeature,
DWORD* pdwUseCount, // optional
WORD* pwDateUsed // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szProduct | LPCWSTR | in |
| szFeature | LPCWSTR | in |
| pdwUseCount | DWORD* | outoptional |
| pwDateUsed | WORD* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// msi.dll (Unicode / -W)
#include <windows.h>
DWORD MsiGetFeatureUsageW(
LPCWSTR szProduct,
LPCWSTR szFeature,
DWORD* pdwUseCount, // optional
WORD* pwDateUsed // optional
);[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiGetFeatureUsageW(
[MarshalAs(UnmanagedType.LPWStr)] string szProduct, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szFeature, // LPCWSTR
IntPtr pdwUseCount, // DWORD* optional, out
IntPtr pwDateUsed // WORD* optional, out
);<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiGetFeatureUsageW(
<MarshalAs(UnmanagedType.LPWStr)> szProduct As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szFeature As String, ' LPCWSTR
pdwUseCount As IntPtr, ' DWORD* optional, out
pwDateUsed As IntPtr ' WORD* optional, out
) As UInteger
End Function' szProduct : LPCWSTR
' szFeature : LPCWSTR
' pdwUseCount : DWORD* optional, out
' pwDateUsed : WORD* optional, out
Declare PtrSafe Function MsiGetFeatureUsageW Lib "msi" ( _
ByVal szProduct As LongPtr, _
ByVal szFeature As LongPtr, _
ByVal pdwUseCount As LongPtr, _
ByVal pwDateUsed 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
MsiGetFeatureUsageW = ctypes.windll.msi.MsiGetFeatureUsageW
MsiGetFeatureUsageW.restype = wintypes.DWORD
MsiGetFeatureUsageW.argtypes = [
wintypes.LPCWSTR, # szProduct : LPCWSTR
wintypes.LPCWSTR, # szFeature : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # pdwUseCount : DWORD* optional, out
ctypes.POINTER(ctypes.c_ushort), # pwDateUsed : WORD* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiGetFeatureUsageW = Fiddle::Function.new(
lib['MsiGetFeatureUsageW'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCWSTR
Fiddle::TYPE_VOIDP, # szFeature : LPCWSTR
Fiddle::TYPE_VOIDP, # pdwUseCount : DWORD* optional, out
Fiddle::TYPE_VOIDP, # pwDateUsed : WORD* optional, out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "msi")]
extern "system" {
fn MsiGetFeatureUsageW(
szProduct: *const u16, // LPCWSTR
szFeature: *const u16, // LPCWSTR
pdwUseCount: *mut u32, // DWORD* optional, out
pwDateUsed: *mut u16 // WORD* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiGetFeatureUsageW([MarshalAs(UnmanagedType.LPWStr)] string szProduct, [MarshalAs(UnmanagedType.LPWStr)] string szFeature, IntPtr pdwUseCount, IntPtr pwDateUsed);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiGetFeatureUsageW' -Namespace Win32 -PassThru
# $api::MsiGetFeatureUsageW(szProduct, szFeature, pdwUseCount, pwDateUsed)#uselib "msi.dll"
#func global MsiGetFeatureUsageW "MsiGetFeatureUsageW" wptr, wptr, wptr, wptr
; MsiGetFeatureUsageW szProduct, szFeature, varptr(pdwUseCount), varptr(pwDateUsed) ; 戻り値は stat
; szProduct : LPCWSTR -> "wptr"
; szFeature : LPCWSTR -> "wptr"
; pdwUseCount : DWORD* optional, out -> "wptr"
; pwDateUsed : WORD* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "msi.dll" #cfunc global MsiGetFeatureUsageW "MsiGetFeatureUsageW" wstr, wstr, var, var ; res = MsiGetFeatureUsageW(szProduct, szFeature, pdwUseCount, pwDateUsed) ; szProduct : LPCWSTR -> "wstr" ; szFeature : LPCWSTR -> "wstr" ; pdwUseCount : DWORD* optional, out -> "var" ; pwDateUsed : WORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "msi.dll" #cfunc global MsiGetFeatureUsageW "MsiGetFeatureUsageW" wstr, wstr, sptr, sptr ; res = MsiGetFeatureUsageW(szProduct, szFeature, varptr(pdwUseCount), varptr(pwDateUsed)) ; szProduct : LPCWSTR -> "wstr" ; szFeature : LPCWSTR -> "wstr" ; pdwUseCount : DWORD* optional, out -> "sptr" ; pwDateUsed : WORD* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD MsiGetFeatureUsageW(LPCWSTR szProduct, LPCWSTR szFeature, DWORD* pdwUseCount, WORD* pwDateUsed) #uselib "msi.dll" #cfunc global MsiGetFeatureUsageW "MsiGetFeatureUsageW" wstr, wstr, var, var ; res = MsiGetFeatureUsageW(szProduct, szFeature, pdwUseCount, pwDateUsed) ; szProduct : LPCWSTR -> "wstr" ; szFeature : LPCWSTR -> "wstr" ; pdwUseCount : DWORD* optional, out -> "var" ; pwDateUsed : WORD* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD MsiGetFeatureUsageW(LPCWSTR szProduct, LPCWSTR szFeature, DWORD* pdwUseCount, WORD* pwDateUsed) #uselib "msi.dll" #cfunc global MsiGetFeatureUsageW "MsiGetFeatureUsageW" wstr, wstr, intptr, intptr ; res = MsiGetFeatureUsageW(szProduct, szFeature, varptr(pdwUseCount), varptr(pwDateUsed)) ; szProduct : LPCWSTR -> "wstr" ; szFeature : LPCWSTR -> "wstr" ; pdwUseCount : DWORD* optional, out -> "intptr" ; pwDateUsed : WORD* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiGetFeatureUsageW = msi.NewProc("MsiGetFeatureUsageW")
)
// szProduct (LPCWSTR), szFeature (LPCWSTR), pdwUseCount (DWORD* optional, out), pwDateUsed (WORD* optional, out)
r1, _, err := procMsiGetFeatureUsageW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szProduct))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFeature))),
uintptr(pdwUseCount),
uintptr(pwDateUsed),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction MsiGetFeatureUsageW(
szProduct: PWideChar; // LPCWSTR
szFeature: PWideChar; // LPCWSTR
pdwUseCount: Pointer; // DWORD* optional, out
pwDateUsed: Pointer // WORD* optional, out
): DWORD; stdcall;
external 'msi.dll' name 'MsiGetFeatureUsageW';result := DllCall("msi\MsiGetFeatureUsageW"
, "WStr", szProduct ; LPCWSTR
, "WStr", szFeature ; LPCWSTR
, "Ptr", pdwUseCount ; DWORD* optional, out
, "Ptr", pwDateUsed ; WORD* optional, out
, "UInt") ; return: DWORD●MsiGetFeatureUsageW(szProduct, szFeature, pdwUseCount, pwDateUsed) = DLL("msi.dll", "dword MsiGetFeatureUsageW(char*, char*, void*, void*)")
# 呼び出し: MsiGetFeatureUsageW(szProduct, szFeature, pdwUseCount, pwDateUsed)
# szProduct : LPCWSTR -> "char*"
# szFeature : LPCWSTR -> "char*"
# pdwUseCount : DWORD* optional, out -> "void*"
# pwDateUsed : WORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。