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

FreeMibTable

関数
MIBテーブル取得関数が割り当てたメモリを解放する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

void FreeMibTable(
    void* Memory
);

パラメーター

名前方向説明
Memoryvoid*in解放するバッファへのポインター。

戻り値の型: void

公式ドキュメント

ネットワークインターフェイス、アドレス、ルートのテーブルを返す関数(GetIfTable2 や GetAnycastIpAddressTable など)によって割り当てられたバッファを解放します。

戻り値

この関数は値を返しません。

解説(Remarks)

FreeMibTable 関数は Windows Vista 以降で定義されています。

FreeMibTable 関数は、インターフェイス、アドレス、ルートのテーブルを取得するさまざまな関数が使用する内部バッファを解放するために使用します。これらのテーブルが不要になったら、FreeMibTable を呼び出してこれらのテーブルが使用していたメモリを解放する必要があります。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

FreeMibTable = ctypes.windll.iphlpapi.FreeMibTable
FreeMibTable.restype = None
FreeMibTable.argtypes = [
    ctypes.POINTER(None),  # Memory : void*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procFreeMibTable = iphlpapi.NewProc("FreeMibTable")
)

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

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

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

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

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

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

関連項目

公式の関連項目