ホーム › Devices.WebServicesOnDevices › WSDAllocateLinkedMemory
WSDAllocateLinkedMemory
関数親に連結されたWSDAPI用のメモリブロックを確保する。
シグネチャ
// wsdapi.dll
#include <windows.h>
void* WSDAllocateLinkedMemory(
void* pParent,
UINT_PTR cbSize
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pParent | void* | inout | 親メモリブロックへのポインタ。NULLなら新規ルートとして確保され、非NULLなら子として連結される。 |
| cbSize | UINT_PTR | in | 確保するメモリのサイズをバイト単位で指定する。 |
戻り値の型: void*
各言語での呼び出し定義
// wsdapi.dll
#include <windows.h>
void* WSDAllocateLinkedMemory(
void* pParent,
UINT_PTR cbSize
);[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern IntPtr WSDAllocateLinkedMemory(
IntPtr pParent, // void* in/out
UIntPtr cbSize // UINT_PTR
);<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDAllocateLinkedMemory(
pParent As IntPtr, ' void* in/out
cbSize As UIntPtr ' UINT_PTR
) As IntPtr
End Function' pParent : void* in/out
' cbSize : UINT_PTR
Declare PtrSafe Function WSDAllocateLinkedMemory Lib "wsdapi" ( _
ByVal pParent As LongPtr, _
ByVal cbSize As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSDAllocateLinkedMemory = ctypes.windll.wsdapi.WSDAllocateLinkedMemory
WSDAllocateLinkedMemory.restype = ctypes.c_void_p
WSDAllocateLinkedMemory.argtypes = [
ctypes.POINTER(None), # pParent : void* in/out
ctypes.c_size_t, # cbSize : UINT_PTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wsdapi.dll')
WSDAllocateLinkedMemory = Fiddle::Function.new(
lib['WSDAllocateLinkedMemory'],
[
Fiddle::TYPE_VOIDP, # pParent : void* in/out
Fiddle::TYPE_UINTPTR_T, # cbSize : UINT_PTR
],
Fiddle::TYPE_VOIDP)#[link(name = "wsdapi")]
extern "system" {
fn WSDAllocateLinkedMemory(
pParent: *mut (), // void* in/out
cbSize: usize // UINT_PTR
) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsdapi.dll")]
public static extern IntPtr WSDAllocateLinkedMemory(IntPtr pParent, UIntPtr cbSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDAllocateLinkedMemory' -Namespace Win32 -PassThru
# $api::WSDAllocateLinkedMemory(pParent, cbSize)#uselib "wsdapi.dll"
#func global WSDAllocateLinkedMemory "WSDAllocateLinkedMemory" sptr, sptr
; WSDAllocateLinkedMemory pParent, cbSize ; 戻り値は stat
; pParent : void* in/out -> "sptr"
; cbSize : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wsdapi.dll"
#cfunc global WSDAllocateLinkedMemory "WSDAllocateLinkedMemory" sptr, sptr
; res = WSDAllocateLinkedMemory(pParent, cbSize)
; pParent : void* in/out -> "sptr"
; cbSize : UINT_PTR -> "sptr"; void* WSDAllocateLinkedMemory(void* pParent, UINT_PTR cbSize)
#uselib "wsdapi.dll"
#cfunc global WSDAllocateLinkedMemory "WSDAllocateLinkedMemory" intptr, intptr
; res = WSDAllocateLinkedMemory(pParent, cbSize)
; pParent : void* in/out -> "intptr"
; cbSize : UINT_PTR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
procWSDAllocateLinkedMemory = wsdapi.NewProc("WSDAllocateLinkedMemory")
)
// pParent (void* in/out), cbSize (UINT_PTR)
r1, _, err := procWSDAllocateLinkedMemory.Call(
uintptr(pParent),
uintptr(cbSize),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // void*function WSDAllocateLinkedMemory(
pParent: Pointer; // void* in/out
cbSize: NativeUInt // UINT_PTR
): Pointer; stdcall;
external 'wsdapi.dll' name 'WSDAllocateLinkedMemory';result := DllCall("wsdapi\WSDAllocateLinkedMemory"
, "Ptr", pParent ; void* in/out
, "UPtr", cbSize ; UINT_PTR
, "Ptr") ; return: void*●WSDAllocateLinkedMemory(pParent, cbSize) = DLL("wsdapi.dll", "void* WSDAllocateLinkedMemory(void*, int)")
# 呼び出し: WSDAllocateLinkedMemory(pParent, cbSize)
# pParent : void* in/out -> "void*"
# cbSize : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsdapi" fn WSDAllocateLinkedMemory(
pParent: ?*anyopaque, // void* in/out
cbSize: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc WSDAllocateLinkedMemory(
pParent: pointer, # void* in/out
cbSize: uint # UINT_PTR
): pointer {.importc: "WSDAllocateLinkedMemory", stdcall, dynlib: "wsdapi.dll".}pragma(lib, "wsdapi");
extern(Windows)
void* WSDAllocateLinkedMemory(
void* pParent, // void* in/out
size_t cbSize // UINT_PTR
);ccall((:WSDAllocateLinkedMemory, "wsdapi.dll"), stdcall, Ptr{Cvoid},
(Ptr{Cvoid}, Csize_t),
pParent, cbSize)
# pParent : void* in/out -> Ptr{Cvoid}
# cbSize : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* WSDAllocateLinkedMemory(
void* pParent,
uintptr_t cbSize);
]]
local wsdapi = ffi.load("wsdapi")
-- wsdapi.WSDAllocateLinkedMemory(pParent, cbSize)
-- pParent : void* in/out
-- cbSize : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsdapi.dll');
const WSDAllocateLinkedMemory = lib.func('__stdcall', 'WSDAllocateLinkedMemory', 'void *', ['void *', 'uintptr_t']);
// WSDAllocateLinkedMemory(pParent, cbSize)
// pParent : void* in/out -> 'void *'
// cbSize : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsdapi.dll", {
WSDAllocateLinkedMemory: { parameters: ["pointer", "usize"], result: "pointer" },
});
// lib.symbols.WSDAllocateLinkedMemory(pParent, cbSize)
// pParent : void* in/out -> "pointer"
// cbSize : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* WSDAllocateLinkedMemory(
void* pParent,
size_t cbSize);
C, "wsdapi.dll");
// $ffi->WSDAllocateLinkedMemory(pParent, cbSize);
// pParent : void* in/out
// cbSize : UINT_PTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wsdapi extends StdCallLibrary {
Wsdapi INSTANCE = Native.load("wsdapi", Wsdapi.class);
Pointer WSDAllocateLinkedMemory(
Pointer pParent, // void* in/out
long cbSize // UINT_PTR
);
}@[Link("wsdapi")]
lib Libwsdapi
fun WSDAllocateLinkedMemory = WSDAllocateLinkedMemory(
pParent : Void*, # void* in/out
cbSize : LibC::SizeT # UINT_PTR
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WSDAllocateLinkedMemoryNative = Pointer<Void> Function(Pointer<Void>, UintPtr);
typedef WSDAllocateLinkedMemoryDart = Pointer<Void> Function(Pointer<Void>, int);
final WSDAllocateLinkedMemory = DynamicLibrary.open('wsdapi.dll')
.lookupFunction<WSDAllocateLinkedMemoryNative, WSDAllocateLinkedMemoryDart>('WSDAllocateLinkedMemory');
// pParent : void* in/out -> Pointer<Void>
// cbSize : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WSDAllocateLinkedMemory(
pParent: Pointer; // void* in/out
cbSize: NativeUInt // UINT_PTR
): Pointer; stdcall;
external 'wsdapi.dll' name 'WSDAllocateLinkedMemory';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSDAllocateLinkedMemory"
c_WSDAllocateLinkedMemory :: Ptr () -> CUIntPtr -> IO (Ptr ())
-- pParent : void* in/out -> Ptr ()
-- cbSize : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsdallocatelinkedmemory =
foreign "WSDAllocateLinkedMemory"
((ptr void) @-> size_t @-> returning (ptr void))
(* pParent : void* in/out -> (ptr void) *)
(* cbSize : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsdapi (t "wsdapi.dll"))
(cffi:use-foreign-library wsdapi)
(cffi:defcfun ("WSDAllocateLinkedMemory" wsdallocate-linked-memory :convention :stdcall) :pointer
(p-parent :pointer) ; void* in/out
(cb-size :uint64)) ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WSDAllocateLinkedMemory = Win32::API::More->new('wsdapi',
'LPVOID WSDAllocateLinkedMemory(LPVOID pParent, WPARAM cbSize)');
# my $ret = $WSDAllocateLinkedMemory->Call($pParent, $cbSize);
# pParent : void* in/out -> LPVOID
# cbSize : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。