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

SetupConfigureWmiFromInfSectionW

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

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupConfigureWmiFromInfSectionW(
    void* InfHandle,
    LPCWSTR SectionName,
    DWORD Flags
);

パラメーター

名前方向
InfHandlevoid*in
SectionNameLPCWSTRin
FlagsDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupConfigureWmiFromInfSectionW(
    void* InfHandle,
    LPCWSTR SectionName,
    DWORD Flags
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool SetupConfigureWmiFromInfSectionW(
    IntPtr InfHandle,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string SectionName,   // LPCWSTR
    uint Flags   // DWORD
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SetupConfigureWmiFromInfSectionW(
    InfHandle As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> SectionName As String,   ' LPCWSTR
    Flags As UInteger   ' DWORD
) As Boolean
End Function
' InfHandle : void*
' SectionName : LPCWSTR
' Flags : DWORD
Declare PtrSafe Function SetupConfigureWmiFromInfSectionW Lib "setupapi" ( _
    ByVal InfHandle As LongPtr, _
    ByVal SectionName As LongPtr, _
    ByVal Flags As Long) 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

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

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

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupConfigureWmiFromInfSectionW = setupapi.NewProc("SetupConfigureWmiFromInfSectionW")
)

// InfHandle (void*), SectionName (LPCWSTR), Flags (DWORD)
r1, _, err := procSetupConfigureWmiFromInfSectionW.Call(
	uintptr(InfHandle),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(SectionName))),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupConfigureWmiFromInfSectionW(
  InfHandle: Pointer;   // void*
  SectionName: PWideChar;   // LPCWSTR
  Flags: DWORD   // DWORD
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupConfigureWmiFromInfSectionW';
result := DllCall("SETUPAPI\SetupConfigureWmiFromInfSectionW"
    , "Ptr", InfHandle   ; void*
    , "WStr", SectionName   ; LPCWSTR
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: BOOL
●SetupConfigureWmiFromInfSectionW(InfHandle, SectionName, Flags) = DLL("SETUPAPI.dll", "bool SetupConfigureWmiFromInfSectionW(void*, char*, dword)")
# 呼び出し: SetupConfigureWmiFromInfSectionW(InfHandle, SectionName, Flags)
# InfHandle : void* -> "void*"
# SectionName : LPCWSTR -> "char*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。