ホーム › Devices.DeviceAndDriverInstallation › SetupConfigureWmiFromInfSectionA
SetupConfigureWmiFromInfSectionA
関数INFセクションの記述に従いWMIを構成する。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
BOOL SetupConfigureWmiFromInfSectionA(
void* InfHandle,
LPCSTR SectionName,
DWORD Flags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| InfHandle | void* | in | 対象INFファイルを開いたハンドルを指定する。SetupOpenInfFileで取得する。 |
| SectionName | LPCSTR | in | 処理するINFセクション名を表すNULL終端のANSI文字列を指定する。WMIインターフェイス設定セクションを指す。 |
| Flags | DWORD | in | 動作を制御するフラグ。通常は0を指定する。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "setupapi" fn SetupConfigureWmiFromInfSectionA(
InfHandle: ?*anyopaque, // void*
SectionName: [*c]const u8, // LPCSTR
Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc SetupConfigureWmiFromInfSectionA(
InfHandle: pointer, # void*
SectionName: cstring, # LPCSTR
Flags: uint32 # DWORD
): int32 {.importc: "SetupConfigureWmiFromInfSectionA", stdcall, dynlib: "SETUPAPI.dll".}pragma(lib, "setupapi");
extern(Windows)
int SetupConfigureWmiFromInfSectionA(
void* InfHandle, // void*
const(char)* SectionName, // LPCSTR
uint Flags // DWORD
);ccall((:SetupConfigureWmiFromInfSectionA, "SETUPAPI.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cstring, UInt32),
InfHandle, SectionName, Flags)
# InfHandle : void* -> Ptr{Cvoid}
# SectionName : LPCSTR -> Cstring
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SetupConfigureWmiFromInfSectionA(
void* InfHandle,
const char* SectionName,
uint32_t Flags);
]]
local setupapi = ffi.load("setupapi")
-- setupapi.SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
-- InfHandle : void*
-- SectionName : LPCSTR
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SETUPAPI.dll');
const SetupConfigureWmiFromInfSectionA = lib.func('__stdcall', 'SetupConfigureWmiFromInfSectionA', 'int32_t', ['void *', 'str', 'uint32_t']);
// SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
// InfHandle : void* -> 'void *'
// SectionName : LPCSTR -> 'str'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SETUPAPI.dll", {
SetupConfigureWmiFromInfSectionA: { parameters: ["pointer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags)
// InfHandle : void* -> "pointer"
// SectionName : LPCSTR -> "buffer"
// Flags : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SetupConfigureWmiFromInfSectionA(
void* InfHandle,
const char* SectionName,
uint32_t Flags);
C, "SETUPAPI.dll");
// $ffi->SetupConfigureWmiFromInfSectionA(InfHandle, SectionName, Flags);
// InfHandle : void*
// SectionName : LPCSTR
// Flags : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Setupapi extends StdCallLibrary {
Setupapi INSTANCE = Native.load("setupapi", Setupapi.class, W32APIOptions.ASCII_OPTIONS);
boolean SetupConfigureWmiFromInfSectionA(
Pointer InfHandle, // void*
String SectionName, // LPCSTR
int Flags // DWORD
);
}@[Link("setupapi")]
lib LibSETUPAPI
fun SetupConfigureWmiFromInfSectionA = SetupConfigureWmiFromInfSectionA(
InfHandle : Void*, # void*
SectionName : UInt8*, # LPCSTR
Flags : UInt32 # DWORD
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SetupConfigureWmiFromInfSectionANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Uint32);
typedef SetupConfigureWmiFromInfSectionADart = int Function(Pointer<Void>, Pointer<Utf8>, int);
final SetupConfigureWmiFromInfSectionA = DynamicLibrary.open('SETUPAPI.dll')
.lookupFunction<SetupConfigureWmiFromInfSectionANative, SetupConfigureWmiFromInfSectionADart>('SetupConfigureWmiFromInfSectionA');
// InfHandle : void* -> Pointer<Void>
// SectionName : LPCSTR -> Pointer<Utf8>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SetupConfigureWmiFromInfSectionA(
InfHandle: Pointer; // void*
SectionName: PAnsiChar; // LPCSTR
Flags: DWORD // DWORD
): BOOL; stdcall;
external 'SETUPAPI.dll' name 'SetupConfigureWmiFromInfSectionA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SetupConfigureWmiFromInfSectionA"
c_SetupConfigureWmiFromInfSectionA :: Ptr () -> CString -> Word32 -> IO CInt
-- InfHandle : void* -> Ptr ()
-- SectionName : LPCSTR -> CString
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let setupconfigurewmifrominfsectiona =
foreign "SetupConfigureWmiFromInfSectionA"
((ptr void) @-> string @-> uint32_t @-> returning int32_t)
(* InfHandle : void* -> (ptr void) *)
(* SectionName : LPCSTR -> string *)
(* Flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library setupapi (t "SETUPAPI.dll"))
(cffi:use-foreign-library setupapi)
(cffi:defcfun ("SetupConfigureWmiFromInfSectionA" setup-configure-wmi-from-inf-section-a :convention :stdcall) :int32
(inf-handle :pointer) ; void*
(section-name :string) ; LPCSTR
(flags :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SetupConfigureWmiFromInfSectionA = Win32::API::More->new('SETUPAPI',
'BOOL SetupConfigureWmiFromInfSectionA(LPVOID InfHandle, LPCSTR SectionName, DWORD Flags)');
# my $ret = $SetupConfigureWmiFromInfSectionA->Call($InfHandle, $SectionName, $Flags);
# InfHandle : void* -> LPVOID
# SectionName : LPCSTR -> LPCSTR
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f SetupConfigureWmiFromInfSectionW (Unicode版) — INFセクションの記述に従いWMIを構成する。