ホーム › System.Console › SetConsoleCP
SetConsoleCP
関数コンソールの入力コードページを設定する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL SetConsoleCP(
DWORD wCodePageID
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| wCodePageID | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL SetConsoleCP(
DWORD wCodePageID
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetConsoleCP(
uint wCodePageID // DWORD
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetConsoleCP(
wCodePageID As UInteger ' DWORD
) As Boolean
End Function' wCodePageID : DWORD
Declare PtrSafe Function SetConsoleCP Lib "kernel32" ( _
ByVal wCodePageID As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetConsoleCP = ctypes.windll.kernel32.SetConsoleCP
SetConsoleCP.restype = wintypes.BOOL
SetConsoleCP.argtypes = [
wintypes.DWORD, # wCodePageID : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
SetConsoleCP = Fiddle::Function.new(
lib['SetConsoleCP'],
[
-Fiddle::TYPE_INT, # wCodePageID : DWORD
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn SetConsoleCP(
wCodePageID: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool SetConsoleCP(uint wCodePageID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_SetConsoleCP' -Namespace Win32 -PassThru
# $api::SetConsoleCP(wCodePageID)#uselib "KERNEL32.dll"
#func global SetConsoleCP "SetConsoleCP" sptr
; SetConsoleCP wCodePageID ; 戻り値は stat
; wCodePageID : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global SetConsoleCP "SetConsoleCP" int
; res = SetConsoleCP(wCodePageID)
; wCodePageID : DWORD -> "int"; BOOL SetConsoleCP(DWORD wCodePageID)
#uselib "KERNEL32.dll"
#cfunc global SetConsoleCP "SetConsoleCP" int
; res = SetConsoleCP(wCodePageID)
; wCodePageID : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procSetConsoleCP = kernel32.NewProc("SetConsoleCP")
)
// wCodePageID (DWORD)
r1, _, err := procSetConsoleCP.Call(
uintptr(wCodePageID),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction SetConsoleCP(
wCodePageID: DWORD // DWORD
): BOOL; stdcall;
external 'KERNEL32.dll' name 'SetConsoleCP';result := DllCall("KERNEL32\SetConsoleCP"
, "UInt", wCodePageID ; DWORD
, "Int") ; return: BOOL●SetConsoleCP(wCodePageID) = DLL("KERNEL32.dll", "bool SetConsoleCP(dword)")
# 呼び出し: SetConsoleCP(wCodePageID)
# wCodePageID : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。