Win32 API 日本語リファレンス
ホームSystem.Console › GetConsoleCommandHistoryLengthA

GetConsoleCommandHistoryLengthA

関数
指定した実行ファイルのコマンド履歴のバイト長を取得する(ANSI版)。
DLLKERNEL32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

DWORD GetConsoleCommandHistoryLengthA(
    LPSTR ExeName
);

パラメーター

名前方向
ExeNameLPSTRin

戻り値の型: DWORD

各言語での呼び出し定義

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

DWORD GetConsoleCommandHistoryLengthA(
    LPSTR ExeName
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint GetConsoleCommandHistoryLengthA(
    [MarshalAs(UnmanagedType.LPStr)] string ExeName   // LPSTR
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetConsoleCommandHistoryLengthA(
    <MarshalAs(UnmanagedType.LPStr)> ExeName As String   ' LPSTR
) As UInteger
End Function
' ExeName : LPSTR
Declare PtrSafe Function GetConsoleCommandHistoryLengthA Lib "kernel32" ( _
    ByVal ExeName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetConsoleCommandHistoryLengthA = ctypes.windll.kernel32.GetConsoleCommandHistoryLengthA
GetConsoleCommandHistoryLengthA.restype = wintypes.DWORD
GetConsoleCommandHistoryLengthA.argtypes = [
    wintypes.LPCSTR,  # ExeName : LPSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetConsoleCommandHistoryLengthA = Fiddle::Function.new(
  lib['GetConsoleCommandHistoryLengthA'],
  [
    Fiddle::TYPE_VOIDP,  # ExeName : LPSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetConsoleCommandHistoryLengthA(
        ExeName: *mut u8  // LPSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi)]
public static extern uint GetConsoleCommandHistoryLengthA([MarshalAs(UnmanagedType.LPStr)] string ExeName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetConsoleCommandHistoryLengthA' -Namespace Win32 -PassThru
# $api::GetConsoleCommandHistoryLengthA(ExeName)
#uselib "KERNEL32.dll"
#func global GetConsoleCommandHistoryLengthA "GetConsoleCommandHistoryLengthA" sptr
; GetConsoleCommandHistoryLengthA ExeName   ; 戻り値は stat
; ExeName : LPSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "KERNEL32.dll"
#cfunc global GetConsoleCommandHistoryLengthA "GetConsoleCommandHistoryLengthA" str
; res = GetConsoleCommandHistoryLengthA(ExeName)
; ExeName : LPSTR -> "str"
; DWORD GetConsoleCommandHistoryLengthA(LPSTR ExeName)
#uselib "KERNEL32.dll"
#cfunc global GetConsoleCommandHistoryLengthA "GetConsoleCommandHistoryLengthA" str
; res = GetConsoleCommandHistoryLengthA(ExeName)
; ExeName : LPSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetConsoleCommandHistoryLengthA = kernel32.NewProc("GetConsoleCommandHistoryLengthA")
)

// ExeName (LPSTR)
r1, _, err := procGetConsoleCommandHistoryLengthA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ExeName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetConsoleCommandHistoryLengthA(
  ExeName: PAnsiChar   // LPSTR
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'GetConsoleCommandHistoryLengthA';
result := DllCall("KERNEL32\GetConsoleCommandHistoryLengthA"
    , "AStr", ExeName   ; LPSTR
    , "UInt")   ; return: DWORD
●GetConsoleCommandHistoryLengthA(ExeName) = DLL("KERNEL32.dll", "dword GetConsoleCommandHistoryLengthA(char*)")
# 呼び出し: GetConsoleCommandHistoryLengthA(ExeName)
# ExeName : LPSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。