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