Win32 API 日本語リファレンス
ホームGraphics.Gdi › GetObjectW

GetObjectW

関数
GDIオブジェクトの情報を構造体に取得する(Unicode版)。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT GetObjectW(
    HGDIOBJ h,
    INT c,
    void* pv   // optional
);

パラメーター

名前方向
hHGDIOBJin
cINTin
pvvoid*outoptional

戻り値の型: INT

各言語での呼び出し定義

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

INT GetObjectW(
    HGDIOBJ h,
    INT c,
    void* pv   // optional
);
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int GetObjectW(
    IntPtr h,   // HGDIOBJ
    int c,   // INT
    IntPtr pv   // void* optional, out
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetObjectW(
    h As IntPtr,   ' HGDIOBJ
    c As Integer,   ' INT
    pv As IntPtr   ' void* optional, out
) As Integer
End Function
' h : HGDIOBJ
' c : INT
' pv : void* optional, out
Declare PtrSafe Function GetObjectW Lib "gdi32" ( _
    ByVal h As LongPtr, _
    ByVal c As Long, _
    ByVal pv 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

GetObjectW = ctypes.windll.gdi32.GetObjectW
GetObjectW.restype = ctypes.c_int
GetObjectW.argtypes = [
    wintypes.HANDLE,  # h : HGDIOBJ
    ctypes.c_int,  # c : INT
    ctypes.POINTER(None),  # pv : void* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
GetObjectW = Fiddle::Function.new(
  lib['GetObjectW'],
  [
    Fiddle::TYPE_VOIDP,  # h : HGDIOBJ
    Fiddle::TYPE_INT,  # c : INT
    Fiddle::TYPE_VOIDP,  # pv : void* optional, out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "gdi32")]
extern "system" {
    fn GetObjectW(
        h: *mut core::ffi::c_void,  // HGDIOBJ
        c: i32,  // INT
        pv: *mut ()  // void* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern int GetObjectW(IntPtr h, int c, IntPtr pv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetObjectW' -Namespace Win32 -PassThru
# $api::GetObjectW(h, c, pv)
#uselib "GDI32.dll"
#func global GetObjectW "GetObjectW" wptr, wptr, wptr
; GetObjectW h, c, pv   ; 戻り値は stat
; h : HGDIOBJ -> "wptr"
; c : INT -> "wptr"
; pv : void* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global GetObjectW "GetObjectW" sptr, int, sptr
; res = GetObjectW(h, c, pv)
; h : HGDIOBJ -> "sptr"
; c : INT -> "int"
; pv : void* optional, out -> "sptr"
; INT GetObjectW(HGDIOBJ h, INT c, void* pv)
#uselib "GDI32.dll"
#cfunc global GetObjectW "GetObjectW" intptr, int, intptr
; res = GetObjectW(h, c, pv)
; h : HGDIOBJ -> "intptr"
; c : INT -> "int"
; pv : void* optional, out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetObjectW = gdi32.NewProc("GetObjectW")
)

// h (HGDIOBJ), c (INT), pv (void* optional, out)
r1, _, err := procGetObjectW.Call(
	uintptr(h),
	uintptr(c),
	uintptr(pv),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function GetObjectW(
  h: THandle;   // HGDIOBJ
  c: Integer;   // INT
  pv: Pointer   // void* optional, out
): Integer; stdcall;
  external 'GDI32.dll' name 'GetObjectW';
result := DllCall("GDI32\GetObjectW"
    , "Ptr", h   ; HGDIOBJ
    , "Int", c   ; INT
    , "Ptr", pv   ; void* optional, out
    , "Int")   ; return: INT
●GetObjectW(h, c, pv) = DLL("GDI32.dll", "int GetObjectW(void*, int, void*)")
# 呼び出し: GetObjectW(h, c, pv)
# h : HGDIOBJ -> "void*"
# c : INT -> "int"
# pv : void* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。