Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupConfigureWmiFromInfSectionA

SetupConfigureWmiFromInfSectionA

関数
INFセクションの記述に従いWMIを構成する。
DLLSETUPAPI.dll文字セットANSI (-A)呼出規約winapi対応OSwindowsserver2003

シグネチャ

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

BOOL SetupConfigureWmiFromInfSectionA(
    void* InfHandle,
    LPCSTR SectionName,
    DWORD Flags
);

パラメーター

名前方向
InfHandlevoid*in
SectionNameLPCSTRin
FlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetupConfigureWmiFromInfSectionA(
    void* InfHandle,
    LPCSTR SectionName,
    DWORD Flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool SetupConfigureWmiFromInfSectionA(
    IntPtr InfHandle,   // void*
    [MarshalAs(UnmanagedType.LPStr)] string SectionName,   // LPCSTR
    uint Flags   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function SetupConfigureWmiFromInfSectionA(
    InfHandle As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPStr)> SectionName As String,   ' LPCSTR
    Flags As UInteger   ' DWORD
) As Boolean
End Function
' InfHandle : void*
' SectionName : LPCSTR
' Flags : DWORD
Declare PtrSafe Function SetupConfigureWmiFromInfSectionA Lib "setupapi" ( _
    ByVal InfHandle As LongPtr, _
    ByVal SectionName As String, _
    ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetupConfigureWmiFromInfSectionA = ctypes.windll.setupapi.SetupConfigureWmiFromInfSectionA
SetupConfigureWmiFromInfSectionA.restype = wintypes.BOOL
SetupConfigureWmiFromInfSectionA.argtypes = [
    ctypes.POINTER(None),  # InfHandle : void*
    wintypes.LPCSTR,  # SectionName : LPCSTR
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupConfigureWmiFromInfSectionA = Fiddle::Function.new(
  lib['SetupConfigureWmiFromInfSectionA'],
  [
    Fiddle::TYPE_VOIDP,  # InfHandle : void*
    Fiddle::TYPE_VOIDP,  # SectionName : LPCSTR
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "setupapi")]
extern "system" {
    fn SetupConfigureWmiFromInfSectionA(
        InfHandle: *mut (),  // void*
        SectionName: *const u8,  // LPCSTR
        Flags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi)]
public static extern bool SetupConfigureWmiFromInfSectionA(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string SectionName, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupConfigureWmiFromInfSectionA' -Namespace Win32 -PassThru
# $api::SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
#uselib "SETUPAPI.dll"
#func global SetupConfigureWmiFromInfSectionA "SetupConfigureWmiFromInfSectionA" sptr, sptr, sptr
; SetupConfigureWmiFromInfSectionA InfHandle, SectionName, Flags   ; 戻り値は stat
; InfHandle : void* -> "sptr"
; SectionName : LPCSTR -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupConfigureWmiFromInfSectionA "SetupConfigureWmiFromInfSectionA" sptr, str, int
; res = SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
; InfHandle : void* -> "sptr"
; SectionName : LPCSTR -> "str"
; Flags : DWORD -> "int"
; BOOL SetupConfigureWmiFromInfSectionA(void* InfHandle, LPCSTR SectionName, DWORD Flags)
#uselib "SETUPAPI.dll"
#cfunc global SetupConfigureWmiFromInfSectionA "SetupConfigureWmiFromInfSectionA" intptr, str, int
; res = SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
; InfHandle : void* -> "intptr"
; SectionName : LPCSTR -> "str"
; Flags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupConfigureWmiFromInfSectionA = setupapi.NewProc("SetupConfigureWmiFromInfSectionA")
)

// InfHandle (void*), SectionName (LPCSTR), Flags (DWORD)
r1, _, err := procSetupConfigureWmiFromInfSectionA.Call(
	uintptr(InfHandle),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(SectionName))),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupConfigureWmiFromInfSectionA(
  InfHandle: Pointer;   // void*
  SectionName: PAnsiChar;   // LPCSTR
  Flags: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupConfigureWmiFromInfSectionA';
result := DllCall("SETUPAPI\SetupConfigureWmiFromInfSectionA"
    , "Ptr", InfHandle   ; void*
    , "AStr", SectionName   ; LPCSTR
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: BOOL
●SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags) = DLL("SETUPAPI.dll", "bool SetupConfigureWmiFromInfSectionA(void*, char*, dword)")
# 呼び出し: SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
# InfHandle : void* -> "void*"
# SectionName : LPCSTR -> "char*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。