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

WTSFreeMemoryExA

関数
WTS関数が割り当てた型付きメモリを解放する。
DLLWTSAPI32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

// WTSAPI32.dll  (ANSI / -A)
#include <windows.h>

BOOL WTSFreeMemoryExA(
    WTS_TYPE_CLASS WTSTypeClass,
    void* pMemory,
    DWORD NumberOfEntries
);

パラメーター

名前方向
WTSTypeClassWTS_TYPE_CLASSin
pMemoryvoid*in
NumberOfEntriesDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

// WTSAPI32.dll  (ANSI / -A)
#include <windows.h>

BOOL WTSFreeMemoryExA(
    WTS_TYPE_CLASS WTSTypeClass,
    void* pMemory,
    DWORD NumberOfEntries
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WTSAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool WTSFreeMemoryExA(
    int WTSTypeClass,   // WTS_TYPE_CLASS
    IntPtr pMemory,   // void*
    uint NumberOfEntries   // DWORD
);
<DllImport("WTSAPI32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WTSFreeMemoryExA(
    WTSTypeClass As Integer,   ' WTS_TYPE_CLASS
    pMemory As IntPtr,   ' void*
    NumberOfEntries As UInteger   ' DWORD
) As Boolean
End Function
' WTSTypeClass : WTS_TYPE_CLASS
' pMemory : void*
' NumberOfEntries : DWORD
Declare PtrSafe Function WTSFreeMemoryExA Lib "wtsapi32" ( _
    ByVal WTSTypeClass As Long, _
    ByVal pMemory As LongPtr, _
    ByVal NumberOfEntries As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WTSFreeMemoryExA = ctypes.windll.wtsapi32.WTSFreeMemoryExA
WTSFreeMemoryExA.restype = wintypes.BOOL
WTSFreeMemoryExA.argtypes = [
    ctypes.c_int,  # WTSTypeClass : WTS_TYPE_CLASS
    ctypes.POINTER(None),  # pMemory : void*
    wintypes.DWORD,  # NumberOfEntries : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WTSAPI32.dll')
WTSFreeMemoryExA = Fiddle::Function.new(
  lib['WTSFreeMemoryExA'],
  [
    Fiddle::TYPE_INT,  # WTSTypeClass : WTS_TYPE_CLASS
    Fiddle::TYPE_VOIDP,  # pMemory : void*
    -Fiddle::TYPE_INT,  # NumberOfEntries : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "wtsapi32")]
extern "system" {
    fn WTSFreeMemoryExA(
        WTSTypeClass: i32,  // WTS_TYPE_CLASS
        pMemory: *mut (),  // void*
        NumberOfEntries: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WTSAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool WTSFreeMemoryExA(int WTSTypeClass, IntPtr pMemory, uint NumberOfEntries);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WTSAPI32_WTSFreeMemoryExA' -Namespace Win32 -PassThru
# $api::WTSFreeMemoryExA(WTSTypeClass, pMemory, NumberOfEntries)
#uselib "WTSAPI32.dll"
#func global WTSFreeMemoryExA "WTSFreeMemoryExA" sptr, sptr, sptr
; WTSFreeMemoryExA WTSTypeClass, pMemory, NumberOfEntries   ; 戻り値は stat
; WTSTypeClass : WTS_TYPE_CLASS -> "sptr"
; pMemory : void* -> "sptr"
; NumberOfEntries : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WTSAPI32.dll"
#cfunc global WTSFreeMemoryExA "WTSFreeMemoryExA" int, sptr, int
; res = WTSFreeMemoryExA(WTSTypeClass, pMemory, NumberOfEntries)
; WTSTypeClass : WTS_TYPE_CLASS -> "int"
; pMemory : void* -> "sptr"
; NumberOfEntries : DWORD -> "int"
; BOOL WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass, void* pMemory, DWORD NumberOfEntries)
#uselib "WTSAPI32.dll"
#cfunc global WTSFreeMemoryExA "WTSFreeMemoryExA" int, intptr, int
; res = WTSFreeMemoryExA(WTSTypeClass, pMemory, NumberOfEntries)
; WTSTypeClass : WTS_TYPE_CLASS -> "int"
; pMemory : void* -> "intptr"
; NumberOfEntries : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wtsapi32 = windows.NewLazySystemDLL("WTSAPI32.dll")
	procWTSFreeMemoryExA = wtsapi32.NewProc("WTSFreeMemoryExA")
)

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