Win32 API 日本語リファレンス
ホームSystem.Rpc › I_RpcAllocate

I_RpcAllocate

関数
RPCランタイム内部で指定サイズのメモリを割り当てる。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

// RPCRT4.dll
#include <windows.h>

void* I_RpcAllocate(
    DWORD Size
);

パラメーター

名前方向
SizeDWORDin

戻り値の型: void*

各言語での呼び出し定義

// RPCRT4.dll
#include <windows.h>

void* I_RpcAllocate(
    DWORD Size
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern IntPtr I_RpcAllocate(
    uint Size   // DWORD
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function I_RpcAllocate(
    Size As UInteger   ' DWORD
) As IntPtr
End Function
' Size : DWORD
Declare PtrSafe Function I_RpcAllocate Lib "rpcrt4" ( _
    ByVal Size As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

I_RpcAllocate = ctypes.windll.rpcrt4.I_RpcAllocate
I_RpcAllocate.restype = ctypes.c_void_p
I_RpcAllocate.argtypes = [
    wintypes.DWORD,  # Size : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
I_RpcAllocate = Fiddle::Function.new(
  lib['I_RpcAllocate'],
  [
    -Fiddle::TYPE_INT,  # Size : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "rpcrt4")]
extern "system" {
    fn I_RpcAllocate(
        Size: u32  // DWORD
    ) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll")]
public static extern IntPtr I_RpcAllocate(uint Size);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_I_RpcAllocate' -Namespace Win32 -PassThru
# $api::I_RpcAllocate(Size)
#uselib "RPCRT4.dll"
#func global I_RpcAllocate "I_RpcAllocate" sptr
; I_RpcAllocate Size   ; 戻り値は stat
; Size : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RPCRT4.dll"
#cfunc global I_RpcAllocate "I_RpcAllocate" int
; res = I_RpcAllocate(Size)
; Size : DWORD -> "int"
; void* I_RpcAllocate(DWORD Size)
#uselib "RPCRT4.dll"
#cfunc global I_RpcAllocate "I_RpcAllocate" int
; res = I_RpcAllocate(Size)
; Size : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procI_RpcAllocate = rpcrt4.NewProc("I_RpcAllocate")
)

// Size (DWORD)
r1, _, err := procI_RpcAllocate.Call(
	uintptr(Size),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void*
function I_RpcAllocate(
  Size: DWORD   // DWORD
): Pointer; stdcall;
  external 'RPCRT4.dll' name 'I_RpcAllocate';
result := DllCall("RPCRT4\I_RpcAllocate"
    , "UInt", Size   ; DWORD
    , "Ptr")   ; return: void*
●I_RpcAllocate(Size) = DLL("RPCRT4.dll", "void* I_RpcAllocate(dword)")
# 呼び出し: I_RpcAllocate(Size)
# Size : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。