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

GetObjectA

関数
GDIオブジェクトの情報を構造体に取得する(ANSI版)。
DLLGDI32.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

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

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

パラメーター

名前方向
hHGDIOBJin
cINTin
pvvoid*outoptional

戻り値の型: INT

各言語での呼び出し定義

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

INT GetObjectA(
    HGDIOBJ h,
    INT c,
    void* pv   // optional
);
[DllImport("GDI32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int GetObjectA(
    IntPtr h,   // HGDIOBJ
    int c,   // INT
    IntPtr pv   // void* optional, out
);
<DllImport("GDI32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetObjectA(
    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 GetObjectA Lib "gdi32" ( _
    ByVal h As LongPtr, _
    ByVal c As Long, _
    ByVal pv As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetObjectA = ctypes.windll.gdi32.GetObjectA
GetObjectA.restype = ctypes.c_int
GetObjectA.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')
GetObjectA = Fiddle::Function.new(
  lib['GetObjectA'],
  [
    Fiddle::TYPE_VOIDP,  # h : HGDIOBJ
    Fiddle::TYPE_INT,  # c : INT
    Fiddle::TYPE_VOIDP,  # pv : void* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn GetObjectA(
        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.Ansi)]
public static extern int GetObjectA(IntPtr h, int c, IntPtr pv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetObjectA' -Namespace Win32 -PassThru
# $api::GetObjectA(h, c, pv)
#uselib "GDI32.dll"
#func global GetObjectA "GetObjectA" sptr, sptr, sptr
; GetObjectA h, c, pv   ; 戻り値は stat
; h : HGDIOBJ -> "sptr"
; c : INT -> "sptr"
; pv : void* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global GetObjectA "GetObjectA" sptr, int, sptr
; res = GetObjectA(h, c, pv)
; h : HGDIOBJ -> "sptr"
; c : INT -> "int"
; pv : void* optional, out -> "sptr"
; INT GetObjectA(HGDIOBJ h, INT c, void* pv)
#uselib "GDI32.dll"
#cfunc global GetObjectA "GetObjectA" intptr, int, intptr
; res = GetObjectA(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")
	procGetObjectA = gdi32.NewProc("GetObjectA")
)

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