ホーム › System.ApplicationInstallationAndServicing › MsiUseFeatureA
MsiUseFeatureA
関数機能の使用を記録し利用可能か返す(ANSI版)。
シグネチャ
// msi.dll (ANSI / -A)
#include <windows.h>
INSTALLSTATE MsiUseFeatureA(
LPCSTR szProduct,
LPCSTR szFeature
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szProduct | LPCSTR | in |
| szFeature | LPCSTR | in |
戻り値の型: INSTALLSTATE
各言語での呼び出し定義
// msi.dll (ANSI / -A)
#include <windows.h>
INSTALLSTATE MsiUseFeatureA(
LPCSTR szProduct,
LPCSTR szFeature
);[DllImport("msi.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int MsiUseFeatureA(
[MarshalAs(UnmanagedType.LPStr)] string szProduct, // LPCSTR
[MarshalAs(UnmanagedType.LPStr)] string szFeature // LPCSTR
);<DllImport("msi.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function MsiUseFeatureA(
<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 MsiUseFeatureA 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
MsiUseFeatureA = ctypes.windll.msi.MsiUseFeatureA
MsiUseFeatureA.restype = ctypes.c_int
MsiUseFeatureA.argtypes = [
wintypes.LPCSTR, # szProduct : LPCSTR
wintypes.LPCSTR, # szFeature : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('msi.dll')
MsiUseFeatureA = Fiddle::Function.new(
lib['MsiUseFeatureA'],
[
Fiddle::TYPE_VOIDP, # szProduct : LPCSTR
Fiddle::TYPE_VOIDP, # szFeature : LPCSTR
],
Fiddle::TYPE_INT)#[link(name = "msi")]
extern "system" {
fn MsiUseFeatureA(
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 MsiUseFeatureA([MarshalAs(UnmanagedType.LPStr)] string szProduct, [MarshalAs(UnmanagedType.LPStr)] string szFeature);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiUseFeatureA' -Namespace Win32 -PassThru
# $api::MsiUseFeatureA(szProduct, szFeature)#uselib "msi.dll"
#func global MsiUseFeatureA "MsiUseFeatureA" sptr, sptr
; MsiUseFeatureA szProduct, szFeature ; 戻り値は stat
; szProduct : LPCSTR -> "sptr"
; szFeature : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "msi.dll"
#cfunc global MsiUseFeatureA "MsiUseFeatureA" str, str
; res = MsiUseFeatureA(szProduct, szFeature)
; szProduct : LPCSTR -> "str"
; szFeature : LPCSTR -> "str"; INSTALLSTATE MsiUseFeatureA(LPCSTR szProduct, LPCSTR szFeature)
#uselib "msi.dll"
#cfunc global MsiUseFeatureA "MsiUseFeatureA" str, str
; res = MsiUseFeatureA(szProduct, szFeature)
; szProduct : LPCSTR -> "str"
; szFeature : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
msi = windows.NewLazySystemDLL("msi.dll")
procMsiUseFeatureA = msi.NewProc("MsiUseFeatureA")
)
// szProduct (LPCSTR), szFeature (LPCSTR)
r1, _, err := procMsiUseFeatureA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(szProduct))),
uintptr(unsafe.Pointer(windows.BytePtrFromString(szFeature))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INSTALLSTATEfunction MsiUseFeatureA(
szProduct: PAnsiChar; // LPCSTR
szFeature: PAnsiChar // LPCSTR
): Integer; stdcall;
external 'msi.dll' name 'MsiUseFeatureA';result := DllCall("msi\MsiUseFeatureA"
, "AStr", szProduct ; LPCSTR
, "AStr", szFeature ; LPCSTR
, "Int") ; return: INSTALLSTATE●MsiUseFeatureA(szProduct, szFeature) = DLL("msi.dll", "int MsiUseFeatureA(char*, char*)")
# 呼び出し: MsiUseFeatureA(szProduct, szFeature)
# szProduct : LPCSTR -> "char*"
# szFeature : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。