SHAllocShared
関数プロセス間で共有可能なメモリブロックを確保する。
シグネチャ
// SHLWAPI.dll
#include <windows.h>
HANDLE SHAllocShared(
const void* pvData, // optional
DWORD dwSize,
DWORD dwProcessId
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pvData | void* | inoptional |
| dwSize | DWORD | in |
| dwProcessId | DWORD | in |
戻り値の型: HANDLE
各言語での呼び出し定義
// SHLWAPI.dll
#include <windows.h>
HANDLE SHAllocShared(
const void* pvData, // optional
DWORD dwSize,
DWORD dwProcessId
);[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern IntPtr SHAllocShared(
IntPtr pvData, // void* optional
uint dwSize, // DWORD
uint dwProcessId // DWORD
);<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function SHAllocShared(
pvData As IntPtr, ' void* optional
dwSize As UInteger, ' DWORD
dwProcessId As UInteger ' DWORD
) As IntPtr
End Function' pvData : void* optional
' dwSize : DWORD
' dwProcessId : DWORD
Declare PtrSafe Function SHAllocShared Lib "shlwapi" ( _
ByVal pvData As LongPtr, _
ByVal dwSize As Long, _
ByVal dwProcessId As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHAllocShared = ctypes.windll.shlwapi.SHAllocShared
SHAllocShared.restype = ctypes.c_void_p
SHAllocShared.argtypes = [
ctypes.POINTER(None), # pvData : void* optional
wintypes.DWORD, # dwSize : DWORD
wintypes.DWORD, # dwProcessId : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHLWAPI.dll')
SHAllocShared = Fiddle::Function.new(
lib['SHAllocShared'],
[
Fiddle::TYPE_VOIDP, # pvData : void* optional
-Fiddle::TYPE_INT, # dwSize : DWORD
-Fiddle::TYPE_INT, # dwProcessId : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "shlwapi")]
extern "system" {
fn SHAllocShared(
pvData: *const (), // void* optional
dwSize: u32, // DWORD
dwProcessId: u32 // DWORD
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern IntPtr SHAllocShared(IntPtr pvData, uint dwSize, uint dwProcessId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_SHAllocShared' -Namespace Win32 -PassThru
# $api::SHAllocShared(pvData, dwSize, dwProcessId)#uselib "SHLWAPI.dll"
#func global SHAllocShared "SHAllocShared" sptr, sptr, sptr
; SHAllocShared pvData, dwSize, dwProcessId ; 戻り値は stat
; pvData : void* optional -> "sptr"
; dwSize : DWORD -> "sptr"
; dwProcessId : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHLWAPI.dll"
#cfunc global SHAllocShared "SHAllocShared" sptr, int, int
; res = SHAllocShared(pvData, dwSize, dwProcessId)
; pvData : void* optional -> "sptr"
; dwSize : DWORD -> "int"
; dwProcessId : DWORD -> "int"; HANDLE SHAllocShared(void* pvData, DWORD dwSize, DWORD dwProcessId)
#uselib "SHLWAPI.dll"
#cfunc global SHAllocShared "SHAllocShared" intptr, int, int
; res = SHAllocShared(pvData, dwSize, dwProcessId)
; pvData : void* optional -> "intptr"
; dwSize : DWORD -> "int"
; dwProcessId : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
procSHAllocShared = shlwapi.NewProc("SHAllocShared")
)
// pvData (void* optional), dwSize (DWORD), dwProcessId (DWORD)
r1, _, err := procSHAllocShared.Call(
uintptr(pvData),
uintptr(dwSize),
uintptr(dwProcessId),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction SHAllocShared(
pvData: Pointer; // void* optional
dwSize: DWORD; // DWORD
dwProcessId: DWORD // DWORD
): THandle; stdcall;
external 'SHLWAPI.dll' name 'SHAllocShared';result := DllCall("SHLWAPI\SHAllocShared"
, "Ptr", pvData ; void* optional
, "UInt", dwSize ; DWORD
, "UInt", dwProcessId ; DWORD
, "Ptr") ; return: HANDLE●SHAllocShared(pvData, dwSize, dwProcessId) = DLL("SHLWAPI.dll", "void* SHAllocShared(void*, dword, dword)")
# 呼び出し: SHAllocShared(pvData, dwSize, dwProcessId)
# pvData : void* optional -> "void*"
# dwSize : DWORD -> "dword"
# dwProcessId : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。