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

SetConsoleInputExeNameW

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

シグネチャ

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

BOOL SetConsoleInputExeNameW(
    LPWSTR lpExeName
);

パラメーター

名前方向
lpExeNameLPWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

BOOL SetConsoleInputExeNameW(
    LPWSTR lpExeName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool SetConsoleInputExeNameW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpExeName   // LPWSTR
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SetConsoleInputExeNameW(
    <MarshalAs(UnmanagedType.LPWStr)> lpExeName As String   ' LPWSTR
) As Boolean
End Function
' lpExeName : LPWSTR
Declare PtrSafe Function SetConsoleInputExeNameW Lib "kernel32" ( _
    ByVal lpExeName As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetConsoleInputExeNameW = ctypes.windll.kernel32.SetConsoleInputExeNameW
SetConsoleInputExeNameW.restype = wintypes.BOOL
SetConsoleInputExeNameW.argtypes = [
    wintypes.LPCWSTR,  # lpExeName : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procSetConsoleInputExeNameW = kernel32.NewProc("SetConsoleInputExeNameW")
)

// lpExeName (LPWSTR)
r1, _, err := procSetConsoleInputExeNameW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpExeName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetConsoleInputExeNameW(
  lpExeName: PWideChar   // LPWSTR
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'SetConsoleInputExeNameW';
result := DllCall("KERNEL32\SetConsoleInputExeNameW"
    , "WStr", lpExeName   ; LPWSTR
    , "Int")   ; return: BOOL
●SetConsoleInputExeNameW(lpExeName) = DLL("KERNEL32.dll", "bool SetConsoleInputExeNameW(char*)")
# 呼び出し: SetConsoleInputExeNameW(lpExeName)
# lpExeName : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。