ホーム › System.Memory › LocalHandle
LocalHandle
関数ポインタから対応するローカルメモリハンドルを取得する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
HLOCAL LocalHandle(
const void* pMem
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pMem | void* | in |
戻り値の型: HLOCAL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
HLOCAL LocalHandle(
const void* pMem
);[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr LocalHandle(
IntPtr pMem // void*
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function LocalHandle(
pMem As IntPtr ' void*
) As IntPtr
End Function' pMem : void*
Declare PtrSafe Function LocalHandle 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
LocalHandle = ctypes.windll.kernel32.LocalHandle
LocalHandle.restype = ctypes.c_void_p
LocalHandle.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')
LocalHandle = Fiddle::Function.new(
lib['LocalHandle'],
[
Fiddle::TYPE_VOIDP, # pMem : void*
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn LocalHandle(
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 LocalHandle(IntPtr pMem);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_LocalHandle' -Namespace Win32 -PassThru
# $api::LocalHandle(pMem)#uselib "KERNEL32.dll"
#func global LocalHandle "LocalHandle" sptr
; LocalHandle pMem ; 戻り値は stat
; pMem : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global LocalHandle "LocalHandle" sptr
; res = LocalHandle(pMem)
; pMem : void* -> "sptr"; HLOCAL LocalHandle(void* pMem)
#uselib "KERNEL32.dll"
#cfunc global LocalHandle "LocalHandle" intptr
; res = LocalHandle(pMem)
; pMem : void* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procLocalHandle = kernel32.NewProc("LocalHandle")
)
// pMem (void*)
r1, _, err := procLocalHandle.Call(
uintptr(pMem),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HLOCALfunction LocalHandle(
pMem: Pointer // void*
): THandle; stdcall;
external 'KERNEL32.dll' name 'LocalHandle';result := DllCall("KERNEL32\LocalHandle"
, "Ptr", pMem ; void*
, "Ptr") ; return: HLOCAL●LocalHandle(pMem) = DLL("KERNEL32.dll", "void* LocalHandle(void*)")
# 呼び出し: LocalHandle(pMem)
# pMem : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。