ホーム › System.ProcessStatus › GetDeviceDriverBaseNameA
GetDeviceDriverBaseNameA
関数デバイスドライバの基本名をANSI文字列で取得する。
シグネチャ
// PSAPI.dll (ANSI / -A)
#include <windows.h>
DWORD GetDeviceDriverBaseNameA(
void* ImageBase,
LPSTR lpFilename,
DWORD nSize
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ImageBase | void* | in |
| lpFilename | LPSTR | out |
| nSize | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// PSAPI.dll (ANSI / -A)
#include <windows.h>
DWORD GetDeviceDriverBaseNameA(
void* ImageBase,
LPSTR lpFilename,
DWORD nSize
);[DllImport("PSAPI.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern uint GetDeviceDriverBaseNameA(
IntPtr ImageBase, // void*
[MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpFilename, // LPSTR out
uint nSize // DWORD
);<DllImport("PSAPI.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetDeviceDriverBaseNameA(
ImageBase As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> lpFilename As System.Text.StringBuilder, ' LPSTR out
nSize As UInteger ' DWORD
) As UInteger
End Function' ImageBase : void*
' lpFilename : LPSTR out
' nSize : DWORD
Declare PtrSafe Function GetDeviceDriverBaseNameA Lib "psapi" ( _
ByVal ImageBase As LongPtr, _
ByVal lpFilename As String, _
ByVal nSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetDeviceDriverBaseNameA = ctypes.windll.psapi.GetDeviceDriverBaseNameA
GetDeviceDriverBaseNameA.restype = wintypes.DWORD
GetDeviceDriverBaseNameA.argtypes = [
ctypes.POINTER(None), # ImageBase : void*
wintypes.LPSTR, # lpFilename : LPSTR out
wintypes.DWORD, # nSize : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('PSAPI.dll')
GetDeviceDriverBaseNameA = Fiddle::Function.new(
lib['GetDeviceDriverBaseNameA'],
[
Fiddle::TYPE_VOIDP, # ImageBase : void*
Fiddle::TYPE_VOIDP, # lpFilename : LPSTR out
-Fiddle::TYPE_INT, # nSize : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "psapi")]
extern "system" {
fn GetDeviceDriverBaseNameA(
ImageBase: *mut (), // void*
lpFilename: *mut u8, // LPSTR out
nSize: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("PSAPI.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern uint GetDeviceDriverBaseNameA(IntPtr ImageBase, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpFilename, uint nSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'PSAPI_GetDeviceDriverBaseNameA' -Namespace Win32 -PassThru
# $api::GetDeviceDriverBaseNameA(ImageBase, lpFilename, nSize)#uselib "PSAPI.dll"
#func global GetDeviceDriverBaseNameA "GetDeviceDriverBaseNameA" sptr, sptr, sptr
; GetDeviceDriverBaseNameA ImageBase, varptr(lpFilename), nSize ; 戻り値は stat
; ImageBase : void* -> "sptr"
; lpFilename : LPSTR out -> "sptr"
; nSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "PSAPI.dll" #cfunc global GetDeviceDriverBaseNameA "GetDeviceDriverBaseNameA" sptr, var, int ; res = GetDeviceDriverBaseNameA(ImageBase, lpFilename, nSize) ; ImageBase : void* -> "sptr" ; lpFilename : LPSTR out -> "var" ; nSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "PSAPI.dll" #cfunc global GetDeviceDriverBaseNameA "GetDeviceDriverBaseNameA" sptr, sptr, int ; res = GetDeviceDriverBaseNameA(ImageBase, varptr(lpFilename), nSize) ; ImageBase : void* -> "sptr" ; lpFilename : LPSTR out -> "sptr" ; nSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetDeviceDriverBaseNameA(void* ImageBase, LPSTR lpFilename, DWORD nSize) #uselib "PSAPI.dll" #cfunc global GetDeviceDriverBaseNameA "GetDeviceDriverBaseNameA" intptr, var, int ; res = GetDeviceDriverBaseNameA(ImageBase, lpFilename, nSize) ; ImageBase : void* -> "intptr" ; lpFilename : LPSTR out -> "var" ; nSize : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetDeviceDriverBaseNameA(void* ImageBase, LPSTR lpFilename, DWORD nSize) #uselib "PSAPI.dll" #cfunc global GetDeviceDriverBaseNameA "GetDeviceDriverBaseNameA" intptr, intptr, int ; res = GetDeviceDriverBaseNameA(ImageBase, varptr(lpFilename), nSize) ; ImageBase : void* -> "intptr" ; lpFilename : LPSTR out -> "intptr" ; nSize : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
psapi = windows.NewLazySystemDLL("PSAPI.dll")
procGetDeviceDriverBaseNameA = psapi.NewProc("GetDeviceDriverBaseNameA")
)
// ImageBase (void*), lpFilename (LPSTR out), nSize (DWORD)
r1, _, err := procGetDeviceDriverBaseNameA.Call(
uintptr(ImageBase),
uintptr(lpFilename),
uintptr(nSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetDeviceDriverBaseNameA(
ImageBase: Pointer; // void*
lpFilename: PAnsiChar; // LPSTR out
nSize: DWORD // DWORD
): DWORD; stdcall;
external 'PSAPI.dll' name 'GetDeviceDriverBaseNameA';result := DllCall("PSAPI\GetDeviceDriverBaseNameA"
, "Ptr", ImageBase ; void*
, "Ptr", lpFilename ; LPSTR out
, "UInt", nSize ; DWORD
, "UInt") ; return: DWORD●GetDeviceDriverBaseNameA(ImageBase, lpFilename, nSize) = DLL("PSAPI.dll", "dword GetDeviceDriverBaseNameA(void*, char*, dword)")
# 呼び出し: GetDeviceDriverBaseNameA(ImageBase, lpFilename, nSize)
# ImageBase : void* -> "void*"
# lpFilename : LPSTR out -> "char*"
# nSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。