ホーム › Devices.DeviceAndDriverInstallation › SetupGetLineCountA
SetupGetLineCountA
関数INFの指定セクション内の行数を取得する(ANSI)。
シグネチャ
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
INT SetupGetLineCountA(
void* InfHandle,
LPCSTR Section
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| InfHandle | void* | in |
| Section | LPCSTR | in |
戻り値の型: INT
各言語での呼び出し定義
// SETUPAPI.dll (ANSI / -A)
#include <windows.h>
INT SetupGetLineCountA(
void* InfHandle,
LPCSTR Section
);[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern int SetupGetLineCountA(
IntPtr InfHandle, // void*
[MarshalAs(UnmanagedType.LPStr)] string Section // LPCSTR
);<DllImport("SETUPAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetupGetLineCountA(
InfHandle As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> Section As String ' LPCSTR
) As Integer
End Function' InfHandle : void*
' Section : LPCSTR
Declare PtrSafe Function SetupGetLineCountA Lib "setupapi" ( _
ByVal InfHandle As LongPtr, _
ByVal Section As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetupGetLineCountA = ctypes.windll.setupapi.SetupGetLineCountA
SetupGetLineCountA.restype = ctypes.c_int
SetupGetLineCountA.argtypes = [
ctypes.POINTER(None), # InfHandle : void*
wintypes.LPCSTR, # Section : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SETUPAPI.dll')
SetupGetLineCountA = Fiddle::Function.new(
lib['SetupGetLineCountA'],
[
Fiddle::TYPE_VOIDP, # InfHandle : void*
Fiddle::TYPE_VOIDP, # Section : LPCSTR
],
Fiddle::TYPE_INT)#[link(name = "setupapi")]
extern "system" {
fn SetupGetLineCountA(
InfHandle: *mut (), // void*
Section: *const u8 // LPCSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SETUPAPI.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern int SetupGetLineCountA(IntPtr InfHandle, [MarshalAs(UnmanagedType.LPStr)] string Section);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupGetLineCountA' -Namespace Win32 -PassThru
# $api::SetupGetLineCountA(InfHandle, Section)#uselib "SETUPAPI.dll"
#func global SetupGetLineCountA "SetupGetLineCountA" sptr, sptr
; SetupGetLineCountA InfHandle, Section ; 戻り値は stat
; InfHandle : void* -> "sptr"
; Section : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SETUPAPI.dll"
#cfunc global SetupGetLineCountA "SetupGetLineCountA" sptr, str
; res = SetupGetLineCountA(InfHandle, Section)
; InfHandle : void* -> "sptr"
; Section : LPCSTR -> "str"; INT SetupGetLineCountA(void* InfHandle, LPCSTR Section)
#uselib "SETUPAPI.dll"
#cfunc global SetupGetLineCountA "SetupGetLineCountA" intptr, str
; res = SetupGetLineCountA(InfHandle, Section)
; InfHandle : void* -> "intptr"
; Section : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
procSetupGetLineCountA = setupapi.NewProc("SetupGetLineCountA")
)
// InfHandle (void*), Section (LPCSTR)
r1, _, err := procSetupGetLineCountA.Call(
uintptr(InfHandle),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Section))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction SetupGetLineCountA(
InfHandle: Pointer; // void*
Section: PAnsiChar // LPCSTR
): Integer; stdcall;
external 'SETUPAPI.dll' name 'SetupGetLineCountA';result := DllCall("SETUPAPI\SetupGetLineCountA"
, "Ptr", InfHandle ; void*
, "AStr", Section ; LPCSTR
, "Int") ; return: INT●SetupGetLineCountA(InfHandle, Section) = DLL("SETUPAPI.dll", "int SetupGetLineCountA(void*, char*)")
# 呼び出し: SetupGetLineCountA(InfHandle, Section)
# InfHandle : void* -> "void*"
# Section : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。