ホーム › System.Memory › GlobalSize
GlobalSize
関数グローバルメモリオブジェクトのサイズを取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
UINT_PTR GlobalSize(
HGLOBAL hMem
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hMem | HGLOBAL | in |
戻り値の型: UINT_PTR
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
UINT_PTR GlobalSize(
HGLOBAL hMem
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern UIntPtr GlobalSize(
IntPtr hMem // HGLOBAL
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GlobalSize(
hMem As IntPtr ' HGLOBAL
) As UIntPtr
End Function' hMem : HGLOBAL
Declare PtrSafe Function GlobalSize Lib "kernel32" ( _
ByVal hMem As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GlobalSize = ctypes.windll.kernel32.GlobalSize
GlobalSize.restype = ctypes.c_size_t
GlobalSize.argtypes = [
wintypes.HANDLE, # hMem : HGLOBAL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GlobalSize = Fiddle::Function.new(
lib['GlobalSize'],
[
Fiddle::TYPE_VOIDP, # hMem : HGLOBAL
],
Fiddle::TYPE_UINTPTR_T)#[link(name = "kernel32")]
extern "system" {
fn GlobalSize(
hMem: *mut core::ffi::c_void // HGLOBAL
) -> usize;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern UIntPtr GlobalSize(IntPtr hMem);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GlobalSize' -Namespace Win32 -PassThru
# $api::GlobalSize(hMem)#uselib "KERNEL32.dll"
#func global GlobalSize "GlobalSize" sptr
; GlobalSize hMem ; 戻り値は stat
; hMem : HGLOBAL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global GlobalSize "GlobalSize" sptr
; res = GlobalSize(hMem)
; hMem : HGLOBAL -> "sptr"; UINT_PTR GlobalSize(HGLOBAL hMem)
#uselib "KERNEL32.dll"
#cfunc global GlobalSize "GlobalSize" intptr
; res = GlobalSize(hMem)
; hMem : HGLOBAL -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGlobalSize = kernel32.NewProc("GlobalSize")
)
// hMem (HGLOBAL)
r1, _, err := procGlobalSize.Call(
uintptr(hMem),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // UINT_PTRfunction GlobalSize(
hMem: THandle // HGLOBAL
): NativeUInt; stdcall;
external 'KERNEL32.dll' name 'GlobalSize';result := DllCall("KERNEL32\GlobalSize"
, "Ptr", hMem ; HGLOBAL
, "UPtr") ; return: UINT_PTR●GlobalSize(hMem) = DLL("KERNEL32.dll", "int GlobalSize(void*)")
# 呼び出し: GlobalSize(hMem)
# hMem : HGLOBAL -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。