ホーム › System.HostComputeSystem › HcsGetServiceProperties
HcsGetServiceProperties
関数HCSサービスのプロパティを取得する。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsGetServiceProperties(
LPCWSTR propertyQuery, // optional
LPWSTR* result
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| propertyQuery | LPCWSTR | inoptional | 取得するサービスプロパティを指定するJSON形式のクエリ文字列。 |
| result | LPWSTR* | out | サービスプロパティのJSON文字列を受け取るポインタ。要解放。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsGetServiceProperties(
LPCWSTR propertyQuery, // optional
LPWSTR* result
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsGetServiceProperties(
[MarshalAs(UnmanagedType.LPWStr)] string propertyQuery, // LPCWSTR optional
IntPtr result // LPWSTR* out
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsGetServiceProperties(
<MarshalAs(UnmanagedType.LPWStr)> propertyQuery As String, ' LPCWSTR optional
result As IntPtr ' LPWSTR* out
) As Integer
End Function' propertyQuery : LPCWSTR optional
' result : LPWSTR* out
Declare PtrSafe Function HcsGetServiceProperties Lib "computecore" ( _
ByVal propertyQuery As LongPtr, _
ByVal result As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsGetServiceProperties = ctypes.windll.computecore.HcsGetServiceProperties
HcsGetServiceProperties.restype = ctypes.c_int
HcsGetServiceProperties.argtypes = [
wintypes.LPCWSTR, # propertyQuery : LPCWSTR optional
ctypes.c_void_p, # result : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsGetServiceProperties = Fiddle::Function.new(
lib['HcsGetServiceProperties'],
[
Fiddle::TYPE_VOIDP, # propertyQuery : LPCWSTR optional
Fiddle::TYPE_VOIDP, # result : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsGetServiceProperties(
propertyQuery: *const u16, // LPCWSTR optional
result: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsGetServiceProperties([MarshalAs(UnmanagedType.LPWStr)] string propertyQuery, IntPtr result);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsGetServiceProperties' -Namespace Win32 -PassThru
# $api::HcsGetServiceProperties(propertyQuery, result)#uselib "computecore.dll"
#func global HcsGetServiceProperties "HcsGetServiceProperties" sptr, sptr
; HcsGetServiceProperties propertyQuery, varptr(result) ; 戻り値は stat
; propertyQuery : LPCWSTR optional -> "sptr"
; result : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "computecore.dll" #cfunc global HcsGetServiceProperties "HcsGetServiceProperties" wstr, var ; res = HcsGetServiceProperties(propertyQuery, result) ; propertyQuery : LPCWSTR optional -> "wstr" ; result : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "computecore.dll" #cfunc global HcsGetServiceProperties "HcsGetServiceProperties" wstr, sptr ; res = HcsGetServiceProperties(propertyQuery, varptr(result)) ; propertyQuery : LPCWSTR optional -> "wstr" ; result : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT HcsGetServiceProperties(LPCWSTR propertyQuery, LPWSTR* result) #uselib "computecore.dll" #cfunc global HcsGetServiceProperties "HcsGetServiceProperties" wstr, var ; res = HcsGetServiceProperties(propertyQuery, result) ; propertyQuery : LPCWSTR optional -> "wstr" ; result : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT HcsGetServiceProperties(LPCWSTR propertyQuery, LPWSTR* result) #uselib "computecore.dll" #cfunc global HcsGetServiceProperties "HcsGetServiceProperties" wstr, intptr ; res = HcsGetServiceProperties(propertyQuery, varptr(result)) ; propertyQuery : LPCWSTR optional -> "wstr" ; result : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsGetServiceProperties = computecore.NewProc("HcsGetServiceProperties")
)
// propertyQuery (LPCWSTR optional), result (LPWSTR* out)
r1, _, err := procHcsGetServiceProperties.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(propertyQuery))),
uintptr(result),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsGetServiceProperties(
propertyQuery: PWideChar; // LPCWSTR optional
result: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'computecore.dll' name 'HcsGetServiceProperties';result := DllCall("computecore\HcsGetServiceProperties"
, "WStr", propertyQuery ; LPCWSTR optional
, "Ptr", result ; LPWSTR* out
, "Int") ; return: HRESULT●HcsGetServiceProperties(propertyQuery, result) = DLL("computecore.dll", "int HcsGetServiceProperties(char*, void*)")
# 呼び出し: HcsGetServiceProperties(propertyQuery, result)
# propertyQuery : LPCWSTR optional -> "char*"
# result : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computecore" fn HcsGetServiceProperties(
propertyQuery: [*c]const u16, // LPCWSTR optional
result: [*c][*c]u16 // LPWSTR* out
) callconv(std.os.windows.WINAPI) i32;proc HcsGetServiceProperties(
propertyQuery: WideCString, # LPCWSTR optional
result: ptr WideCString # LPWSTR* out
): int32 {.importc: "HcsGetServiceProperties", stdcall, dynlib: "computecore.dll".}pragma(lib, "computecore");
extern(Windows)
int HcsGetServiceProperties(
const(wchar)* propertyQuery, // LPCWSTR optional
wchar** result // LPWSTR* out
);ccall((:HcsGetServiceProperties, "computecore.dll"), stdcall, Int32,
(Cwstring, Ptr{Ptr{UInt16}}),
propertyQuery, result)
# propertyQuery : LPCWSTR optional -> Cwstring
# result : LPWSTR* out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsGetServiceProperties(
const uint16_t* propertyQuery,
uint16_t** result);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsGetServiceProperties(propertyQuery, result)
-- propertyQuery : LPCWSTR optional
-- result : LPWSTR* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsGetServiceProperties = lib.func('__stdcall', 'HcsGetServiceProperties', 'int32_t', ['str16', 'void *']);
// HcsGetServiceProperties(propertyQuery, result)
// propertyQuery : LPCWSTR optional -> 'str16'
// result : LPWSTR* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computecore.dll", {
HcsGetServiceProperties: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.HcsGetServiceProperties(propertyQuery, result)
// propertyQuery : LPCWSTR optional -> "buffer"
// result : LPWSTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsGetServiceProperties(
const uint16_t* propertyQuery,
uint16_t** result);
C, "computecore.dll");
// $ffi->HcsGetServiceProperties(propertyQuery, result);
// propertyQuery : LPCWSTR optional
// result : LPWSTR* 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 Computecore extends StdCallLibrary {
Computecore INSTANCE = Native.load("computecore", Computecore.class);
int HcsGetServiceProperties(
WString propertyQuery, // LPCWSTR optional
PointerByReference result // LPWSTR* out
);
}@[Link("computecore")]
lib Libcomputecore
fun HcsGetServiceProperties = HcsGetServiceProperties(
propertyQuery : UInt16*, # LPCWSTR optional
result : UInt16** # LPWSTR* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HcsGetServicePropertiesNative = Int32 Function(Pointer<Utf16>, Pointer<Pointer<Utf16>>);
typedef HcsGetServicePropertiesDart = int Function(Pointer<Utf16>, Pointer<Pointer<Utf16>>);
final HcsGetServiceProperties = DynamicLibrary.open('computecore.dll')
.lookupFunction<HcsGetServicePropertiesNative, HcsGetServicePropertiesDart>('HcsGetServiceProperties');
// propertyQuery : LPCWSTR optional -> Pointer<Utf16>
// result : LPWSTR* out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsGetServiceProperties(
propertyQuery: PWideChar; // LPCWSTR optional
result: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'computecore.dll' name 'HcsGetServiceProperties';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsGetServiceProperties"
c_HcsGetServiceProperties :: CWString -> Ptr CWString -> IO Int32
-- propertyQuery : LPCWSTR optional -> CWString
-- result : LPWSTR* out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcsgetserviceproperties =
foreign "HcsGetServiceProperties"
((ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* propertyQuery : LPCWSTR optional -> (ptr uint16_t) *)
(* result : LPWSTR* out -> (ptr (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 ("HcsGetServiceProperties" hcs-get-service-properties :convention :stdcall) :int32
(property-query (:string :encoding :utf-16le)) ; LPCWSTR optional
(result :pointer)) ; LPWSTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsGetServiceProperties = Win32::API::More->new('computecore',
'int HcsGetServiceProperties(LPCWSTR propertyQuery, LPVOID result)');
# my $ret = $HcsGetServiceProperties->Call($propertyQuery, $result);
# propertyQuery : LPCWSTR optional -> LPCWSTR
# result : LPWSTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。