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

HcsGetProcessProperties

関数
コンピュートシステム内プロセスのプロパティを取得する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsGetProcessProperties(
    HCS_PROCESS process,
    HCS_OPERATION operation,
    LPCWSTR propertyQuery   // optional
);

パラメーター

名前方向説明
processHCS_PROCESSinプロパティを取得する対象のプロセスハンドル。
operationHCS_OPERATIONin結果を受け取る非同期HCS操作のハンドル。
propertyQueryLPCWSTRinoptional取得するプロパティを指定するJSON形式のクエリ文字列。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsGetProcessProperties(
    HCS_PROCESS process,
    HCS_OPERATION operation,
    LPCWSTR propertyQuery   // optional
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsGetProcessProperties(
    IntPtr process,   // HCS_PROCESS
    IntPtr operation,   // HCS_OPERATION
    [MarshalAs(UnmanagedType.LPWStr)] string propertyQuery   // LPCWSTR optional
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsGetProcessProperties(
    process As IntPtr,   ' HCS_PROCESS
    operation As IntPtr,   ' HCS_OPERATION
    <MarshalAs(UnmanagedType.LPWStr)> propertyQuery As String   ' LPCWSTR optional
) As Integer
End Function
' process : HCS_PROCESS
' operation : HCS_OPERATION
' propertyQuery : LPCWSTR optional
Declare PtrSafe Function HcsGetProcessProperties Lib "computecore" ( _
    ByVal process As LongPtr, _
    ByVal operation As LongPtr, _
    ByVal propertyQuery As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HcsGetProcessProperties = ctypes.windll.computecore.HcsGetProcessProperties
HcsGetProcessProperties.restype = ctypes.c_int
HcsGetProcessProperties.argtypes = [
    wintypes.HANDLE,  # process : HCS_PROCESS
    wintypes.HANDLE,  # operation : HCS_OPERATION
    wintypes.LPCWSTR,  # propertyQuery : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('computecore.dll')
HcsGetProcessProperties = Fiddle::Function.new(
  lib['HcsGetProcessProperties'],
  [
    Fiddle::TYPE_VOIDP,  # process : HCS_PROCESS
    Fiddle::TYPE_VOIDP,  # operation : HCS_OPERATION
    Fiddle::TYPE_VOIDP,  # propertyQuery : LPCWSTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "computecore")]
extern "system" {
    fn HcsGetProcessProperties(
        process: *mut core::ffi::c_void,  // HCS_PROCESS
        operation: *mut core::ffi::c_void,  // HCS_OPERATION
        propertyQuery: *const u16  // LPCWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsGetProcessProperties(IntPtr process, IntPtr operation, [MarshalAs(UnmanagedType.LPWStr)] string propertyQuery);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsGetProcessProperties' -Namespace Win32 -PassThru
# $api::HcsGetProcessProperties(process, operation, propertyQuery)
#uselib "computecore.dll"
#func global HcsGetProcessProperties "HcsGetProcessProperties" sptr, sptr, sptr
; HcsGetProcessProperties process, operation, propertyQuery   ; 戻り値は stat
; process : HCS_PROCESS -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; propertyQuery : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "computecore.dll"
#cfunc global HcsGetProcessProperties "HcsGetProcessProperties" sptr, sptr, wstr
; res = HcsGetProcessProperties(process, operation, propertyQuery)
; process : HCS_PROCESS -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; propertyQuery : LPCWSTR optional -> "wstr"
; HRESULT HcsGetProcessProperties(HCS_PROCESS process, HCS_OPERATION operation, LPCWSTR propertyQuery)
#uselib "computecore.dll"
#cfunc global HcsGetProcessProperties "HcsGetProcessProperties" intptr, intptr, wstr
; res = HcsGetProcessProperties(process, operation, propertyQuery)
; process : HCS_PROCESS -> "intptr"
; operation : HCS_OPERATION -> "intptr"
; propertyQuery : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsGetProcessProperties = computecore.NewProc("HcsGetProcessProperties")
)

// process (HCS_PROCESS), operation (HCS_OPERATION), propertyQuery (LPCWSTR optional)
r1, _, err := procHcsGetProcessProperties.Call(
	uintptr(process),
	uintptr(operation),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(propertyQuery))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HcsGetProcessProperties(
  process: THandle;   // HCS_PROCESS
  operation: THandle;   // HCS_OPERATION
  propertyQuery: PWideChar   // LPCWSTR optional
): Integer; stdcall;
  external 'computecore.dll' name 'HcsGetProcessProperties';
result := DllCall("computecore\HcsGetProcessProperties"
    , "Ptr", process   ; HCS_PROCESS
    , "Ptr", operation   ; HCS_OPERATION
    , "WStr", propertyQuery   ; LPCWSTR optional
    , "Int")   ; return: HRESULT
●HcsGetProcessProperties(process, operation, propertyQuery) = DLL("computecore.dll", "int HcsGetProcessProperties(void*, void*, char*)")
# 呼び出し: HcsGetProcessProperties(process, operation, propertyQuery)
# process : HCS_PROCESS -> "void*"
# operation : HCS_OPERATION -> "void*"
# propertyQuery : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef HcsGetProcessPropertiesNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
typedef HcsGetProcessPropertiesDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
final HcsGetProcessProperties = DynamicLibrary.open('computecore.dll')
    .lookupFunction<HcsGetProcessPropertiesNative, HcsGetProcessPropertiesDart>('HcsGetProcessProperties');
// process : HCS_PROCESS -> Pointer<Void>
// operation : HCS_OPERATION -> Pointer<Void>
// propertyQuery : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HcsGetProcessProperties(
  process: THandle;   // HCS_PROCESS
  operation: THandle;   // HCS_OPERATION
  propertyQuery: PWideChar   // LPCWSTR optional
): Integer; stdcall;
  external 'computecore.dll' name 'HcsGetProcessProperties';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HcsGetProcessProperties"
  c_HcsGetProcessProperties :: Ptr () -> Ptr () -> CWString -> IO Int32
-- process : HCS_PROCESS -> Ptr ()
-- operation : HCS_OPERATION -> Ptr ()
-- propertyQuery : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hcsgetprocessproperties =
  foreign "HcsGetProcessProperties"
    ((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* process : HCS_PROCESS -> (ptr void) *)
(* operation : HCS_OPERATION -> (ptr void) *)
(* propertyQuery : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)

(cffi:defcfun ("HcsGetProcessProperties" hcs-get-process-properties :convention :stdcall) :int32
  (process :pointer)   ; HCS_PROCESS
  (operation :pointer)   ; HCS_OPERATION
  (property-query (:string :encoding :utf-16le)))   ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HcsGetProcessProperties = Win32::API::More->new('computecore',
    'int HcsGetProcessProperties(HANDLE process, HANDLE operation, LPCWSTR propertyQuery)');
# my $ret = $HcsGetProcessProperties->Call($process, $operation, $propertyQuery);
# process : HCS_PROCESS -> HANDLE
# operation : HCS_OPERATION -> HANDLE
# propertyQuery : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。