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

GetObjectType

関数
指定したGDIオブジェクトの種類を取得する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll
#include <windows.h>

DWORD GetObjectType(
    HGDIOBJ h
);

パラメーター

名前方向
hHGDIOBJin

戻り値の型: DWORD

各言語での呼び出し定義

// GDI32.dll
#include <windows.h>

DWORD GetObjectType(
    HGDIOBJ h
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern uint GetObjectType(
    IntPtr h   // HGDIOBJ
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function GetObjectType(
    h As IntPtr   ' HGDIOBJ
) As UInteger
End Function
' h : HGDIOBJ
Declare PtrSafe Function GetObjectType Lib "gdi32" ( _
    ByVal h As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetObjectType = ctypes.windll.gdi32.GetObjectType
GetObjectType.restype = wintypes.DWORD
GetObjectType.argtypes = [
    wintypes.HANDLE,  # h : HGDIOBJ
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
GetObjectType = Fiddle::Function.new(
  lib['GetObjectType'],
  [
    Fiddle::TYPE_VOIDP,  # h : HGDIOBJ
  ],
  -Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn GetObjectType(
        h: *mut core::ffi::c_void  // HGDIOBJ
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern uint GetObjectType(IntPtr h);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetObjectType' -Namespace Win32 -PassThru
# $api::GetObjectType(h)
#uselib "GDI32.dll"
#func global GetObjectType "GetObjectType" sptr
; GetObjectType h   ; 戻り値は stat
; h : HGDIOBJ -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global GetObjectType "GetObjectType" sptr
; res = GetObjectType(h)
; h : HGDIOBJ -> "sptr"
; DWORD GetObjectType(HGDIOBJ h)
#uselib "GDI32.dll"
#cfunc global GetObjectType "GetObjectType" intptr
; res = GetObjectType(h)
; h : HGDIOBJ -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetObjectType = gdi32.NewProc("GetObjectType")
)

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