K32EnumPageFilesA
関数シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL K32EnumPageFilesA(
PENUM_PAGE_FILE_CALLBACKA pCallBackRoutine,
void* pContext
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pCallBackRoutine | PENUM_PAGE_FILE_CALLBACKA | in | 各ページファイルに対して呼び出されるルーチンへのポインターです。詳細については、 EnumPageFilesProc を参照してください。 |
| pContext | void* | inout | コールバックルーチンに渡されるユーザー定義のデータです。 |
戻り値の型: BOOL
公式ドキュメント
システムにインストールされている各ページファイルに対してコールバックルーチンを呼び出します。(ANSI)
戻り値
関数が成功した場合、戻り値は TRUE です。関数が失敗した場合、戻り値は FALSE です。拡張エラー情報を取得するには、 GetLastError を呼び出します。
解説(Remarks)
Windows 7 および Windows Server 2008 R2 以降、Psapi.h は PSAPI 関数のバージョン番号を定義します。PSAPI のバージョン番号は、関数の呼び出しに使用される名前と、プログラムが読み込む必要のあるライブラリに影響します。
PSAPI_VERSION が 2 以上の場合、この関数は Psapi.h で K32EnumPageFiles として定義され、Kernel32.lib および Kernel32.dll からエクスポートされます。PSAPI_VERSION が 1 の場合、この関数は Psapi.h で EnumPageFiles として定義され、K32EnumPageFiles を呼び出すラッパーとして Psapi.lib および Psapi.dll からエクスポートされます。
以前のバージョンの Windows と Windows 7 以降のバージョンの両方で実行する必要のあるプログラムは、常にこの関数を EnumPageFiles として呼び出す必要があります。シンボルが正しく解決されるようにするには、TARGETLIBS マクロに Psapi.lib を追加し、–DPSAPI_VERSION=1 を指定してプログラムをコンパイルします。実行時の動的リンクを使用するには、Psapi.dll を読み込みます。
psapi.h ヘッダーは EnumPageFiles を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、コンパイルエラーや実行時エラーを引き起こす不一致が生じる可能性があります。詳細については、関数プロトタイプの規則 を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
BOOL K32EnumPageFilesA(
PENUM_PAGE_FILE_CALLBACKA pCallBackRoutine,
void* pContext
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool K32EnumPageFilesA(
IntPtr pCallBackRoutine, // PENUM_PAGE_FILE_CALLBACKA
IntPtr pContext // void* in/out
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function K32EnumPageFilesA(
pCallBackRoutine As IntPtr, ' PENUM_PAGE_FILE_CALLBACKA
pContext As IntPtr ' void* in/out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA
' pContext : void* in/out
Declare PtrSafe Function K32EnumPageFilesA Lib "kernel32" ( _
ByVal pCallBackRoutine As LongPtr, _
ByVal pContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
K32EnumPageFilesA = ctypes.windll.kernel32.K32EnumPageFilesA
K32EnumPageFilesA.restype = wintypes.BOOL
K32EnumPageFilesA.argtypes = [
ctypes.c_void_p, # pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA
ctypes.POINTER(None), # pContext : void* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
K32EnumPageFilesA = Fiddle::Function.new(
lib['K32EnumPageFilesA'],
[
Fiddle::TYPE_VOIDP, # pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA
Fiddle::TYPE_VOIDP, # pContext : void* in/out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn K32EnumPageFilesA(
pCallBackRoutine: *const core::ffi::c_void, // PENUM_PAGE_FILE_CALLBACKA
pContext: *mut () // void* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi)]
public static extern bool K32EnumPageFilesA(IntPtr pCallBackRoutine, IntPtr pContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_K32EnumPageFilesA' -Namespace Win32 -PassThru
# $api::K32EnumPageFilesA(pCallBackRoutine, pContext)#uselib "KERNEL32.dll"
#func global K32EnumPageFilesA "K32EnumPageFilesA" sptr, sptr
; K32EnumPageFilesA pCallBackRoutine, pContext ; 戻り値は stat
; pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> "sptr"
; pContext : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global K32EnumPageFilesA "K32EnumPageFilesA" sptr, sptr
; res = K32EnumPageFilesA(pCallBackRoutine, pContext)
; pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> "sptr"
; pContext : void* in/out -> "sptr"; BOOL K32EnumPageFilesA(PENUM_PAGE_FILE_CALLBACKA pCallBackRoutine, void* pContext)
#uselib "KERNEL32.dll"
#cfunc global K32EnumPageFilesA "K32EnumPageFilesA" intptr, intptr
; res = K32EnumPageFilesA(pCallBackRoutine, pContext)
; pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> "intptr"
; pContext : void* in/out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procK32EnumPageFilesA = kernel32.NewProc("K32EnumPageFilesA")
)
// pCallBackRoutine (PENUM_PAGE_FILE_CALLBACKA), pContext (void* in/out)
r1, _, err := procK32EnumPageFilesA.Call(
uintptr(pCallBackRoutine),
uintptr(pContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction K32EnumPageFilesA(
pCallBackRoutine: Pointer; // PENUM_PAGE_FILE_CALLBACKA
pContext: Pointer // void* in/out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'K32EnumPageFilesA';result := DllCall("KERNEL32\K32EnumPageFilesA"
, "Ptr", pCallBackRoutine ; PENUM_PAGE_FILE_CALLBACKA
, "Ptr", pContext ; void* in/out
, "Int") ; return: BOOL●K32EnumPageFilesA(pCallBackRoutine, pContext) = DLL("KERNEL32.dll", "bool K32EnumPageFilesA(void*, void*)")
# 呼び出し: K32EnumPageFilesA(pCallBackRoutine, pContext)
# pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> "void*"
# pContext : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn K32EnumPageFilesA(
pCallBackRoutine: ?*anyopaque, // PENUM_PAGE_FILE_CALLBACKA
pContext: ?*anyopaque // void* in/out
) callconv(std.os.windows.WINAPI) i32;proc K32EnumPageFilesA(
pCallBackRoutine: pointer, # PENUM_PAGE_FILE_CALLBACKA
pContext: pointer # void* in/out
): int32 {.importc: "K32EnumPageFilesA", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int K32EnumPageFilesA(
void* pCallBackRoutine, // PENUM_PAGE_FILE_CALLBACKA
void* pContext // void* in/out
);ccall((:K32EnumPageFilesA, "KERNEL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}),
pCallBackRoutine, pContext)
# pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> Ptr{Cvoid}
# pContext : void* in/out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t K32EnumPageFilesA(
void* pCallBackRoutine,
void* pContext);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.K32EnumPageFilesA(pCallBackRoutine, pContext)
-- pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA
-- pContext : void* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const K32EnumPageFilesA = lib.func('__stdcall', 'K32EnumPageFilesA', 'int32_t', ['void *', 'void *']);
// K32EnumPageFilesA(pCallBackRoutine, pContext)
// pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> 'void *'
// pContext : void* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("KERNEL32.dll", {
K32EnumPageFilesA: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.K32EnumPageFilesA(pCallBackRoutine, pContext)
// pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> "pointer"
// pContext : void* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t K32EnumPageFilesA(
void* pCallBackRoutine,
void* pContext);
C, "KERNEL32.dll");
// $ffi->K32EnumPageFilesA(pCallBackRoutine, pContext);
// pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA
// pContext : void* in/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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.ASCII_OPTIONS);
boolean K32EnumPageFilesA(
Callback pCallBackRoutine, // PENUM_PAGE_FILE_CALLBACKA
Pointer pContext // void* in/out
);
}@[Link("kernel32")]
lib LibKERNEL32
fun K32EnumPageFilesA = K32EnumPageFilesA(
pCallBackRoutine : Void*, # PENUM_PAGE_FILE_CALLBACKA
pContext : Void* # void* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef K32EnumPageFilesANative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef K32EnumPageFilesADart = int Function(Pointer<Void>, Pointer<Void>);
final K32EnumPageFilesA = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<K32EnumPageFilesANative, K32EnumPageFilesADart>('K32EnumPageFilesA');
// pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> Pointer<Void>
// pContext : void* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function K32EnumPageFilesA(
pCallBackRoutine: Pointer; // PENUM_PAGE_FILE_CALLBACKA
pContext: Pointer // void* in/out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'K32EnumPageFilesA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "K32EnumPageFilesA"
c_K32EnumPageFilesA :: Ptr () -> Ptr () -> IO CInt
-- pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> Ptr ()
-- pContext : void* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let k32enumpagefilesa =
foreign "K32EnumPageFilesA"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> (ptr void) *)
(* pContext : void* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("K32EnumPageFilesA" k32-enum-page-files-a :convention :stdcall) :int32
(p-call-back-routine :pointer) ; PENUM_PAGE_FILE_CALLBACKA
(p-context :pointer)) ; void* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $K32EnumPageFilesA = Win32::API::More->new('KERNEL32',
'BOOL K32EnumPageFilesA(LPVOID pCallBackRoutine, LPVOID pContext)');
# my $ret = $K32EnumPageFilesA->Call($pCallBackRoutine, $pContext);
# pCallBackRoutine : PENUM_PAGE_FILE_CALLBACKA -> LPVOID
# pContext : void* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
- f K32EnumPageFilesW (Unicode版) — システムのページファイル情報をUnicodeで列挙する。