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

CM_Get_First_Log_Conf

関数
デバイスの最初の論理構成を取得する。
DLLCFGMGR32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// CFGMGR32.dll
#include <windows.h>

CONFIGRET CM_Get_First_Log_Conf(
    UINT_PTR* plcLogConf,   // optional
    DWORD dnDevInst,
    CM_LOG_CONF ulFlags
);

パラメーター

名前方向
plcLogConfUINT_PTR*outoptional
dnDevInstDWORDin
ulFlagsCM_LOG_CONFin

戻り値の型: CONFIGRET

各言語での呼び出し定義

// CFGMGR32.dll
#include <windows.h>

CONFIGRET CM_Get_First_Log_Conf(
    UINT_PTR* plcLogConf,   // optional
    DWORD dnDevInst,
    CM_LOG_CONF ulFlags
);
[DllImport("CFGMGR32.dll", ExactSpelling = true)]
static extern uint CM_Get_First_Log_Conf(
    IntPtr plcLogConf,   // UINT_PTR* optional, out
    uint dnDevInst,   // DWORD
    uint ulFlags   // CM_LOG_CONF
);
<DllImport("CFGMGR32.dll", ExactSpelling:=True)>
Public Shared Function CM_Get_First_Log_Conf(
    plcLogConf As IntPtr,   ' UINT_PTR* optional, out
    dnDevInst As UInteger,   ' DWORD
    ulFlags As UInteger   ' CM_LOG_CONF
) As UInteger
End Function
' plcLogConf : UINT_PTR* optional, out
' dnDevInst : DWORD
' ulFlags : CM_LOG_CONF
Declare PtrSafe Function CM_Get_First_Log_Conf Lib "cfgmgr32" ( _
    ByVal plcLogConf As LongPtr, _
    ByVal dnDevInst As Long, _
    ByVal ulFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CM_Get_First_Log_Conf = ctypes.windll.cfgmgr32.CM_Get_First_Log_Conf
CM_Get_First_Log_Conf.restype = wintypes.DWORD
CM_Get_First_Log_Conf.argtypes = [
    ctypes.POINTER(ctypes.c_size_t),  # plcLogConf : UINT_PTR* optional, out
    wintypes.DWORD,  # dnDevInst : DWORD
    wintypes.DWORD,  # ulFlags : CM_LOG_CONF
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Get_First_Log_Conf = Fiddle::Function.new(
  lib['CM_Get_First_Log_Conf'],
  [
    Fiddle::TYPE_VOIDP,  # plcLogConf : UINT_PTR* optional, out
    -Fiddle::TYPE_INT,  # dnDevInst : DWORD
    -Fiddle::TYPE_INT,  # ulFlags : CM_LOG_CONF
  ],
  -Fiddle::TYPE_INT)
#[link(name = "cfgmgr32")]
extern "system" {
    fn CM_Get_First_Log_Conf(
        plcLogConf: *mut usize,  // UINT_PTR* optional, out
        dnDevInst: u32,  // DWORD
        ulFlags: u32  // CM_LOG_CONF
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CFGMGR32.dll")]
public static extern uint CM_Get_First_Log_Conf(IntPtr plcLogConf, uint dnDevInst, uint ulFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Get_First_Log_Conf' -Namespace Win32 -PassThru
# $api::CM_Get_First_Log_Conf(plcLogConf, dnDevInst, ulFlags)
#uselib "CFGMGR32.dll"
#func global CM_Get_First_Log_Conf "CM_Get_First_Log_Conf" sptr, sptr, sptr
; CM_Get_First_Log_Conf varptr(plcLogConf), dnDevInst, ulFlags   ; 戻り値は stat
; plcLogConf : UINT_PTR* optional, out -> "sptr"
; dnDevInst : DWORD -> "sptr"
; ulFlags : CM_LOG_CONF -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_First_Log_Conf "CM_Get_First_Log_Conf" var, int, int
; res = CM_Get_First_Log_Conf(plcLogConf, dnDevInst, ulFlags)
; plcLogConf : UINT_PTR* optional, out -> "var"
; dnDevInst : DWORD -> "int"
; ulFlags : CM_LOG_CONF -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; CONFIGRET CM_Get_First_Log_Conf(UINT_PTR* plcLogConf, DWORD dnDevInst, CM_LOG_CONF ulFlags)
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_First_Log_Conf "CM_Get_First_Log_Conf" var, int, int
; res = CM_Get_First_Log_Conf(plcLogConf, dnDevInst, ulFlags)
; plcLogConf : UINT_PTR* optional, out -> "var"
; dnDevInst : DWORD -> "int"
; ulFlags : CM_LOG_CONF -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
	procCM_Get_First_Log_Conf = cfgmgr32.NewProc("CM_Get_First_Log_Conf")
)

// plcLogConf (UINT_PTR* optional, out), dnDevInst (DWORD), ulFlags (CM_LOG_CONF)
r1, _, err := procCM_Get_First_Log_Conf.Call(
	uintptr(plcLogConf),
	uintptr(dnDevInst),
	uintptr(ulFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // CONFIGRET
function CM_Get_First_Log_Conf(
  plcLogConf: Pointer;   // UINT_PTR* optional, out
  dnDevInst: DWORD;   // DWORD
  ulFlags: DWORD   // CM_LOG_CONF
): DWORD; stdcall;
  external 'CFGMGR32.dll' name 'CM_Get_First_Log_Conf';
result := DllCall("CFGMGR32\CM_Get_First_Log_Conf"
    , "Ptr", plcLogConf   ; UINT_PTR* optional, out
    , "UInt", dnDevInst   ; DWORD
    , "UInt", ulFlags   ; CM_LOG_CONF
    , "UInt")   ; return: CONFIGRET
●CM_Get_First_Log_Conf(plcLogConf, dnDevInst, ulFlags) = DLL("CFGMGR32.dll", "dword CM_Get_First_Log_Conf(void*, dword, dword)")
# 呼び出し: CM_Get_First_Log_Conf(plcLogConf, dnDevInst, ulFlags)
# plcLogConf : UINT_PTR* optional, out -> "void*"
# dnDevInst : DWORD -> "dword"
# ulFlags : CM_LOG_CONF -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。