ホーム › UI.WindowsAndMessaging › IsWindowUnicode
IsWindowUnicode
関数ウィンドウがUnicode対応かを判定する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL IsWindowUnicode(
HWND hWnd
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hWnd | HWND | in | テスト対象のウィンドウへのハンドル。 |
戻り値の型: BOOL
公式ドキュメント
指定したウィンドウがネイティブの Unicode ウィンドウかどうかを判定します。
戻り値
型: BOOL
ウィンドウがネイティブの Unicode ウィンドウである場合、戻り値は 0 以外になります。
ウィンドウがネイティブの Unicode ウィンドウでない場合、戻り値は 0 になります。このウィンドウはネイティブの ANSI ウィンドウです。
解説(Remarks)
ウィンドウの文字セットは、RegisterClass 関数の使用方法によって決まります。ウィンドウ クラスが ANSI 版の RegisterClass(RegisterClassA)で登録された場合、ウィンドウの文字セットは ANSI になります。ウィンドウ クラスが Unicode 版の RegisterClass(RegisterClassW)で登録された場合、ウィンドウの文字セットは Unicode になります。
システムは、ウィンドウ メッセージに対して自動的に双方向の変換(Unicode から ANSI へ)を行います。たとえば、Unicode 文字セットを使用するウィンドウに ANSI のウィンドウ メッセージが送信された場合、システムはウィンドウ プロシージャを呼び出す前にそのメッセージを Unicode メッセージに変換します。システムは、メッセージを変換するかどうかを判断するために IsWindowUnicode を呼び出します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL IsWindowUnicode(
HWND hWnd
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool IsWindowUnicode(
IntPtr hWnd // HWND
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function IsWindowUnicode(
hWnd As IntPtr ' HWND
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hWnd : HWND
Declare PtrSafe Function IsWindowUnicode Lib "user32" ( _
ByVal hWnd As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsWindowUnicode = ctypes.windll.user32.IsWindowUnicode
IsWindowUnicode.restype = wintypes.BOOL
IsWindowUnicode.argtypes = [
wintypes.HANDLE, # hWnd : HWND
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
IsWindowUnicode = Fiddle::Function.new(
lib['IsWindowUnicode'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn IsWindowUnicode(
hWnd: *mut core::ffi::c_void // HWND
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool IsWindowUnicode(IntPtr hWnd);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_IsWindowUnicode' -Namespace Win32 -PassThru
# $api::IsWindowUnicode(hWnd)#uselib "USER32.dll"
#func global IsWindowUnicode "IsWindowUnicode" sptr
; IsWindowUnicode hWnd ; 戻り値は stat
; hWnd : HWND -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global IsWindowUnicode "IsWindowUnicode" sptr
; res = IsWindowUnicode(hWnd)
; hWnd : HWND -> "sptr"; BOOL IsWindowUnicode(HWND hWnd)
#uselib "USER32.dll"
#cfunc global IsWindowUnicode "IsWindowUnicode" intptr
; res = IsWindowUnicode(hWnd)
; hWnd : HWND -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procIsWindowUnicode = user32.NewProc("IsWindowUnicode")
)
// hWnd (HWND)
r1, _, err := procIsWindowUnicode.Call(
uintptr(hWnd),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsWindowUnicode(
hWnd: THandle // HWND
): BOOL; stdcall;
external 'USER32.dll' name 'IsWindowUnicode';result := DllCall("USER32\IsWindowUnicode"
, "Ptr", hWnd ; HWND
, "Int") ; return: BOOL●IsWindowUnicode(hWnd) = DLL("USER32.dll", "bool IsWindowUnicode(void*)")
# 呼び出し: IsWindowUnicode(hWnd)
# hWnd : HWND -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn IsWindowUnicode(
hWnd: ?*anyopaque // HWND
) callconv(std.os.windows.WINAPI) i32;proc IsWindowUnicode(
hWnd: pointer # HWND
): int32 {.importc: "IsWindowUnicode", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int IsWindowUnicode(
void* hWnd // HWND
);ccall((:IsWindowUnicode, "USER32.dll"), stdcall, Int32,
(Ptr{Cvoid},),
hWnd)
# hWnd : HWND -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IsWindowUnicode(
void* hWnd);
]]
local user32 = ffi.load("user32")
-- user32.IsWindowUnicode(hWnd)
-- hWnd : HWND
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const IsWindowUnicode = lib.func('__stdcall', 'IsWindowUnicode', 'int32_t', ['void *']);
// IsWindowUnicode(hWnd)
// hWnd : HWND -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
IsWindowUnicode: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.IsWindowUnicode(hWnd)
// hWnd : HWND -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IsWindowUnicode(
void* hWnd);
C, "USER32.dll");
// $ffi->IsWindowUnicode(hWnd);
// hWnd : HWND
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class);
boolean IsWindowUnicode(
Pointer hWnd // HWND
);
}@[Link("user32")]
lib LibUSER32
fun IsWindowUnicode = IsWindowUnicode(
hWnd : Void* # HWND
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IsWindowUnicodeNative = Int32 Function(Pointer<Void>);
typedef IsWindowUnicodeDart = int Function(Pointer<Void>);
final IsWindowUnicode = DynamicLibrary.open('USER32.dll')
.lookupFunction<IsWindowUnicodeNative, IsWindowUnicodeDart>('IsWindowUnicode');
// hWnd : HWND -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IsWindowUnicode(
hWnd: THandle // HWND
): BOOL; stdcall;
external 'USER32.dll' name 'IsWindowUnicode';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IsWindowUnicode"
c_IsWindowUnicode :: Ptr () -> IO CInt
-- hWnd : HWND -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let iswindowunicode =
foreign "IsWindowUnicode"
((ptr void) @-> returning int32_t)
(* hWnd : HWND -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("IsWindowUnicode" is-window-unicode :convention :stdcall) :int32
(h-wnd :pointer)) ; HWND
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IsWindowUnicode = Win32::API::More->new('USER32',
'BOOL IsWindowUnicode(HANDLE hWnd)');
# my $ret = $IsWindowUnicode->Call($hWnd);
# hWnd : HWND -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。