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

CM_Get_Version

関数
構成マネージャーのバージョン番号を取得する。
DLLCFGMGR32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

WORD CM_Get_Version(void);

パラメーターなし。戻り値: WORD

各言語での呼び出し定義

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

WORD CM_Get_Version(void);
[DllImport("CFGMGR32.dll", SetLastError = true, ExactSpelling = true)]
static extern ushort CM_Get_Version();
<DllImport("CFGMGR32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CM_Get_Version() As UShort
End Function
Declare PtrSafe Function CM_Get_Version Lib "cfgmgr32" () As Integer
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CM_Get_Version = ctypes.windll.cfgmgr32.CM_Get_Version
CM_Get_Version.restype = ctypes.c_ushort
CM_Get_Version.argtypes = []
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CFGMGR32.dll')
CM_Get_Version = Fiddle::Function.new(
  lib['CM_Get_Version'],
  [],
  -Fiddle::TYPE_SHORT)
#[link(name = "cfgmgr32")]
extern "system" {
    fn CM_Get_Version() -> u16;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CFGMGR32.dll", SetLastError = true)]
public static extern ushort CM_Get_Version();
"@
$api = Add-Type -MemberDefinition $sig -Name 'CFGMGR32_CM_Get_Version' -Namespace Win32 -PassThru
# $api::CM_Get_Version()
#uselib "CFGMGR32.dll"
#func global CM_Get_Version "CM_Get_Version"
; CM_Get_Version   ; 戻り値は stat
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_Version "CM_Get_Version"
; res = CM_Get_Version()
; WORD CM_Get_Version()
#uselib "CFGMGR32.dll"
#cfunc global CM_Get_Version "CM_Get_Version"
; res = CM_Get_Version()
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	cfgmgr32 = windows.NewLazySystemDLL("CFGMGR32.dll")
	procCM_Get_Version = cfgmgr32.NewProc("CM_Get_Version")
)

r1, _, err := procCM_Get_Version.Call()
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WORD
function CM_Get_Version: Word; stdcall;
  external 'CFGMGR32.dll' name 'CM_Get_Version';
result := DllCall("CFGMGR32\CM_Get_Version", "UShort")
●CM_Get_Version() = DLL("CFGMGR32.dll", "int CM_Get_Version()")
# 呼び出し: CM_Get_Version()
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。