ホーム › System.Diagnostics.ProcessSnapshotting › PssQuerySnapshot
PssQuerySnapshot
関数プロセススナップショットから指定種別の情報を照会する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
DWORD PssQuerySnapshot(
HPSS SnapshotHandle,
PSS_QUERY_INFORMATION_CLASS InformationClass,
void* Buffer,
DWORD BufferLength
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| SnapshotHandle | HPSS | in | 情報を問い合わせる対象スナップショットのHPSSハンドル。 |
| InformationClass | PSS_QUERY_INFORMATION_CLASS | in | 取得する情報の種類を指定するPSS_QUERY_INFORMATION_CLASS列挙値。 |
| Buffer | void* | out | 問い合わせ結果を受け取る出力バッファ。InformationClassに応じた構造体を指す。 |
| BufferLength | DWORD | in | Bufferのサイズ(バイト)。 |
戻り値の型: DWORD
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
DWORD PssQuerySnapshot(
HPSS SnapshotHandle,
PSS_QUERY_INFORMATION_CLASS InformationClass,
void* Buffer,
DWORD BufferLength
);[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint PssQuerySnapshot(
IntPtr SnapshotHandle, // HPSS
int InformationClass, // PSS_QUERY_INFORMATION_CLASS
IntPtr Buffer, // void* out
uint BufferLength // DWORD
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function PssQuerySnapshot(
SnapshotHandle As IntPtr, ' HPSS
InformationClass As Integer, ' PSS_QUERY_INFORMATION_CLASS
Buffer As IntPtr, ' void* out
BufferLength As UInteger ' DWORD
) As UInteger
End Function' SnapshotHandle : HPSS
' InformationClass : PSS_QUERY_INFORMATION_CLASS
' Buffer : void* out
' BufferLength : DWORD
Declare PtrSafe Function PssQuerySnapshot Lib "kernel32" ( _
ByVal SnapshotHandle As LongPtr, _
ByVal InformationClass As Long, _
ByVal Buffer As LongPtr, _
ByVal BufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PssQuerySnapshot = ctypes.windll.kernel32.PssQuerySnapshot
PssQuerySnapshot.restype = wintypes.DWORD
PssQuerySnapshot.argtypes = [
wintypes.HANDLE, # SnapshotHandle : HPSS
ctypes.c_int, # InformationClass : PSS_QUERY_INFORMATION_CLASS
ctypes.POINTER(None), # Buffer : void* out
wintypes.DWORD, # BufferLength : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
PssQuerySnapshot = Fiddle::Function.new(
lib['PssQuerySnapshot'],
[
Fiddle::TYPE_VOIDP, # SnapshotHandle : HPSS
Fiddle::TYPE_INT, # InformationClass : PSS_QUERY_INFORMATION_CLASS
Fiddle::TYPE_VOIDP, # Buffer : void* out
-Fiddle::TYPE_INT, # BufferLength : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn PssQuerySnapshot(
SnapshotHandle: *mut core::ffi::c_void, // HPSS
InformationClass: i32, // PSS_QUERY_INFORMATION_CLASS
Buffer: *mut (), // void* out
BufferLength: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll")]
public static extern uint PssQuerySnapshot(IntPtr SnapshotHandle, int InformationClass, IntPtr Buffer, uint BufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_PssQuerySnapshot' -Namespace Win32 -PassThru
# $api::PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)#uselib "KERNEL32.dll"
#func global PssQuerySnapshot "PssQuerySnapshot" sptr, sptr, sptr, sptr
; PssQuerySnapshot SnapshotHandle, InformationClass, Buffer, BufferLength ; 戻り値は stat
; SnapshotHandle : HPSS -> "sptr"
; InformationClass : PSS_QUERY_INFORMATION_CLASS -> "sptr"
; Buffer : void* out -> "sptr"
; BufferLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global PssQuerySnapshot "PssQuerySnapshot" sptr, int, sptr, int
; res = PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)
; SnapshotHandle : HPSS -> "sptr"
; InformationClass : PSS_QUERY_INFORMATION_CLASS -> "int"
; Buffer : void* out -> "sptr"
; BufferLength : DWORD -> "int"; DWORD PssQuerySnapshot(HPSS SnapshotHandle, PSS_QUERY_INFORMATION_CLASS InformationClass, void* Buffer, DWORD BufferLength)
#uselib "KERNEL32.dll"
#cfunc global PssQuerySnapshot "PssQuerySnapshot" intptr, int, intptr, int
; res = PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)
; SnapshotHandle : HPSS -> "intptr"
; InformationClass : PSS_QUERY_INFORMATION_CLASS -> "int"
; Buffer : void* out -> "intptr"
; BufferLength : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procPssQuerySnapshot = kernel32.NewProc("PssQuerySnapshot")
)
// SnapshotHandle (HPSS), InformationClass (PSS_QUERY_INFORMATION_CLASS), Buffer (void* out), BufferLength (DWORD)
r1, _, err := procPssQuerySnapshot.Call(
uintptr(SnapshotHandle),
uintptr(InformationClass),
uintptr(Buffer),
uintptr(BufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PssQuerySnapshot(
SnapshotHandle: THandle; // HPSS
InformationClass: Integer; // PSS_QUERY_INFORMATION_CLASS
Buffer: Pointer; // void* out
BufferLength: DWORD // DWORD
): DWORD; stdcall;
external 'KERNEL32.dll' name 'PssQuerySnapshot';result := DllCall("KERNEL32\PssQuerySnapshot"
, "Ptr", SnapshotHandle ; HPSS
, "Int", InformationClass ; PSS_QUERY_INFORMATION_CLASS
, "Ptr", Buffer ; void* out
, "UInt", BufferLength ; DWORD
, "UInt") ; return: DWORD●PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength) = DLL("KERNEL32.dll", "dword PssQuerySnapshot(void*, int, void*, dword)")
# 呼び出し: PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)
# SnapshotHandle : HPSS -> "void*"
# InformationClass : PSS_QUERY_INFORMATION_CLASS -> "int"
# Buffer : void* out -> "void*"
# BufferLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn PssQuerySnapshot(
SnapshotHandle: ?*anyopaque, // HPSS
InformationClass: i32, // PSS_QUERY_INFORMATION_CLASS
Buffer: ?*anyopaque, // void* out
BufferLength: u32 // DWORD
) callconv(std.os.windows.WINAPI) u32;proc PssQuerySnapshot(
SnapshotHandle: pointer, # HPSS
InformationClass: int32, # PSS_QUERY_INFORMATION_CLASS
Buffer: pointer, # void* out
BufferLength: uint32 # DWORD
): uint32 {.importc: "PssQuerySnapshot", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
uint PssQuerySnapshot(
void* SnapshotHandle, // HPSS
int InformationClass, // PSS_QUERY_INFORMATION_CLASS
void* Buffer, // void* out
uint BufferLength // DWORD
);ccall((:PssQuerySnapshot, "KERNEL32.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Int32, Ptr{Cvoid}, UInt32),
SnapshotHandle, InformationClass, Buffer, BufferLength)
# SnapshotHandle : HPSS -> Ptr{Cvoid}
# InformationClass : PSS_QUERY_INFORMATION_CLASS -> Int32
# Buffer : void* out -> Ptr{Cvoid}
# BufferLength : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PssQuerySnapshot(
void* SnapshotHandle,
int32_t InformationClass,
void* Buffer,
uint32_t BufferLength);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)
-- SnapshotHandle : HPSS
-- InformationClass : PSS_QUERY_INFORMATION_CLASS
-- Buffer : void* out
-- BufferLength : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const PssQuerySnapshot = lib.func('__stdcall', 'PssQuerySnapshot', 'uint32_t', ['void *', 'int32_t', 'void *', 'uint32_t']);
// PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)
// SnapshotHandle : HPSS -> 'void *'
// InformationClass : PSS_QUERY_INFORMATION_CLASS -> 'int32_t'
// Buffer : void* out -> 'void *'
// BufferLength : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
PssQuerySnapshot: { parameters: ["pointer", "i32", "pointer", "u32"], result: "u32" },
});
// lib.symbols.PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength)
// SnapshotHandle : HPSS -> "pointer"
// InformationClass : PSS_QUERY_INFORMATION_CLASS -> "i32"
// Buffer : void* out -> "pointer"
// BufferLength : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PssQuerySnapshot(
void* SnapshotHandle,
int32_t InformationClass,
void* Buffer,
uint32_t BufferLength);
C, "KERNEL32.dll");
// $ffi->PssQuerySnapshot(SnapshotHandle, InformationClass, Buffer, BufferLength);
// SnapshotHandle : HPSS
// InformationClass : PSS_QUERY_INFORMATION_CLASS
// Buffer : void* out
// BufferLength : DWORD
// 構造体/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);
int PssQuerySnapshot(
Pointer SnapshotHandle, // HPSS
int InformationClass, // PSS_QUERY_INFORMATION_CLASS
Pointer Buffer, // void* out
int BufferLength // DWORD
);
}@[Link("kernel32")]
lib LibKERNEL32
fun PssQuerySnapshot = PssQuerySnapshot(
SnapshotHandle : Void*, # HPSS
InformationClass : Int32, # PSS_QUERY_INFORMATION_CLASS
Buffer : Void*, # void* out
BufferLength : UInt32 # DWORD
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PssQuerySnapshotNative = Uint32 Function(Pointer<Void>, Int32, Pointer<Void>, Uint32);
typedef PssQuerySnapshotDart = int Function(Pointer<Void>, int, Pointer<Void>, int);
final PssQuerySnapshot = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<PssQuerySnapshotNative, PssQuerySnapshotDart>('PssQuerySnapshot');
// SnapshotHandle : HPSS -> Pointer<Void>
// InformationClass : PSS_QUERY_INFORMATION_CLASS -> Int32
// Buffer : void* out -> Pointer<Void>
// BufferLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PssQuerySnapshot(
SnapshotHandle: THandle; // HPSS
InformationClass: Integer; // PSS_QUERY_INFORMATION_CLASS
Buffer: Pointer; // void* out
BufferLength: DWORD // DWORD
): DWORD; stdcall;
external 'KERNEL32.dll' name 'PssQuerySnapshot';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PssQuerySnapshot"
c_PssQuerySnapshot :: Ptr () -> Int32 -> Ptr () -> Word32 -> IO Word32
-- SnapshotHandle : HPSS -> Ptr ()
-- InformationClass : PSS_QUERY_INFORMATION_CLASS -> Int32
-- Buffer : void* out -> Ptr ()
-- BufferLength : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pssquerysnapshot =
foreign "PssQuerySnapshot"
((ptr void) @-> int32_t @-> (ptr void) @-> uint32_t @-> returning uint32_t)
(* SnapshotHandle : HPSS -> (ptr void) *)
(* InformationClass : PSS_QUERY_INFORMATION_CLASS -> int32_t *)
(* Buffer : void* out -> (ptr void) *)
(* BufferLength : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("PssQuerySnapshot" pss-query-snapshot :convention :stdcall) :uint32
(snapshot-handle :pointer) ; HPSS
(information-class :int32) ; PSS_QUERY_INFORMATION_CLASS
(buffer :pointer) ; void* out
(buffer-length :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PssQuerySnapshot = Win32::API::More->new('KERNEL32',
'DWORD PssQuerySnapshot(HANDLE SnapshotHandle, int InformationClass, LPVOID Buffer, DWORD BufferLength)');
# my $ret = $PssQuerySnapshot->Call($SnapshotHandle, $InformationClass, $Buffer, $BufferLength);
# SnapshotHandle : HPSS -> HANDLE
# InformationClass : PSS_QUERY_INFORMATION_CLASS -> int
# Buffer : void* out -> LPVOID
# BufferLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。