Win32 API 日本語リファレンス
ホームNetworkManagement.WindowsConnectionManager › WcmFreeMemory

WcmFreeMemory

関数
WCM APIが割り当てたメモリを解放する。
DLLwcmapi.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

void WcmFreeMemory(
    void* pMemory
);

パラメーター

名前方向説明
pMemoryvoid*outWCM系APIが割り当てたメモリへのポインター。解放対象とする。

戻り値の型: void

各言語での呼び出し定義

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

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

WcmFreeMemory = ctypes.windll.wcmapi.WcmFreeMemory
WcmFreeMemory.restype = None
WcmFreeMemory.argtypes = [
    ctypes.POINTER(None),  # pMemory : void* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wcmapi.dll')
WcmFreeMemory = Fiddle::Function.new(
  lib['WcmFreeMemory'],
  [
    Fiddle::TYPE_VOIDP,  # pMemory : void* out
  ],
  Fiddle::TYPE_VOID)
#[link(name = "wcmapi")]
extern "system" {
    fn WcmFreeMemory(
        pMemory: *mut ()  // void* out
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wcmapi.dll")]
public static extern void WcmFreeMemory(IntPtr pMemory);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wcmapi_WcmFreeMemory' -Namespace Win32 -PassThru
# $api::WcmFreeMemory(pMemory)
#uselib "wcmapi.dll"
#func global WcmFreeMemory "WcmFreeMemory" sptr
; WcmFreeMemory pMemory
; pMemory : void* out -> "sptr"
#uselib "wcmapi.dll"
#func global WcmFreeMemory "WcmFreeMemory" sptr
; WcmFreeMemory pMemory
; pMemory : void* out -> "sptr"
; void WcmFreeMemory(void* pMemory)
#uselib "wcmapi.dll"
#func global WcmFreeMemory "WcmFreeMemory" intptr
; WcmFreeMemory pMemory
; pMemory : void* out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wcmapi = windows.NewLazySystemDLL("wcmapi.dll")
	procWcmFreeMemory = wcmapi.NewProc("WcmFreeMemory")
)

// pMemory (void* out)
r1, _, err := procWcmFreeMemory.Call(
	uintptr(pMemory),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure WcmFreeMemory(
  pMemory: Pointer   // void* out
); stdcall;
  external 'wcmapi.dll' name 'WcmFreeMemory';
result := DllCall("wcmapi\WcmFreeMemory"
    , "Ptr", pMemory   ; void* out
    , "Int")   ; return: void
●WcmFreeMemory(pMemory) = DLL("wcmapi.dll", "int WcmFreeMemory(void*)")
# 呼び出し: WcmFreeMemory(pMemory)
# pMemory : void* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wcmapi" fn WcmFreeMemory(
    pMemory: ?*anyopaque // void* out
) callconv(std.os.windows.WINAPI) void;
proc WcmFreeMemory(
    pMemory: pointer  # void* out
) {.importc: "WcmFreeMemory", stdcall, dynlib: "wcmapi.dll".}
pragma(lib, "wcmapi");
extern(Windows)
void WcmFreeMemory(
    void* pMemory   // void* out
);
ccall((:WcmFreeMemory, "wcmapi.dll"), stdcall, Cvoid,
      (Ptr{Cvoid},),
      pMemory)
# pMemory : void* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void WcmFreeMemory(
    void* pMemory);
]]
local wcmapi = ffi.load("wcmapi")
-- wcmapi.WcmFreeMemory(pMemory)
-- pMemory : void* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('wcmapi.dll');
const WcmFreeMemory = lib.func('__stdcall', 'WcmFreeMemory', 'void', ['void *']);
// WcmFreeMemory(pMemory)
// pMemory : void* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("wcmapi.dll", {
  WcmFreeMemory: { parameters: ["pointer"], result: "void" },
});
// lib.symbols.WcmFreeMemory(pMemory)
// pMemory : void* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void WcmFreeMemory(
    void* pMemory);
C, "wcmapi.dll");
// $ffi->WcmFreeMemory(pMemory);
// pMemory : void* out
// 構造体/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 Wcmapi extends StdCallLibrary {
    Wcmapi INSTANCE = Native.load("wcmapi", Wcmapi.class);
    void WcmFreeMemory(
        Pointer pMemory   // void* out
    );
}
@[Link("wcmapi")]
lib Libwcmapi
  fun WcmFreeMemory = WcmFreeMemory(
    pMemory : Void*   # void* out
  ) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef WcmFreeMemoryNative = Void Function(Pointer<Void>);
typedef WcmFreeMemoryDart = void Function(Pointer<Void>);
final WcmFreeMemory = DynamicLibrary.open('wcmapi.dll')
    .lookupFunction<WcmFreeMemoryNative, WcmFreeMemoryDart>('WcmFreeMemory');
// pMemory : void* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
procedure WcmFreeMemory(
  pMemory: Pointer   // void* out
); stdcall;
  external 'wcmapi.dll' name 'WcmFreeMemory';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "WcmFreeMemory"
  c_WcmFreeMemory :: Ptr () -> IO ()
-- pMemory : void* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let wcmfreememory =
  foreign "WcmFreeMemory"
    ((ptr void) @-> returning void)
(* pMemory : void* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wcmapi (t "wcmapi.dll"))
(cffi:use-foreign-library wcmapi)

(cffi:defcfun ("WcmFreeMemory" wcm-free-memory :convention :stdcall) :void
  (p-memory :pointer))   ; void* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $WcmFreeMemory = Win32::API::More->new('wcmapi',
    'void WcmFreeMemory(LPVOID pMemory)');
# my $ret = $WcmFreeMemory->Call($pMemory);
# pMemory : void* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。