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

SetConsoleInputExeNameA

関数
コンソール入力に関連付ける実行ファイル名を設定する(ANSI版)。
DLLKERNEL32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

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

BOOL SetConsoleInputExeNameA(
    LPSTR lpExeName
);

パラメーター

名前方向
lpExeNameLPSTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

SetConsoleInputExeNameA = ctypes.windll.kernel32.SetConsoleInputExeNameA
SetConsoleInputExeNameA.restype = wintypes.BOOL
SetConsoleInputExeNameA.argtypes = [
    wintypes.LPCSTR,  # lpExeName : LPSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetConsoleInputExeNameA = kernel32.NewProc("SetConsoleInputExeNameA")
)

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