ホーム › System.HostComputeSystem › HcsOpenComputeSystemInNamespace
HcsOpenComputeSystemInNamespace
関数指定名前空間内のコンピュートシステムを開く。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsOpenComputeSystemInNamespace(
LPCWSTR idNamespace,
LPCWSTR id,
DWORD requestedAccess,
HCS_SYSTEM* computeSystem
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| idNamespace | LPCWSTR | in | 対象計算システムが属する名前空間の識別文字列。 |
| id | LPCWSTR | in | 開く対象の計算システムを識別するID文字列。 |
| requestedAccess | DWORD | in | 要求するアクセス権を示すビットフラグ。現状は予約され通常0。 |
| computeSystem | HCS_SYSTEM* | out | 開いた計算システムのハンドルを受け取るポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsOpenComputeSystemInNamespace(
LPCWSTR idNamespace,
LPCWSTR id,
DWORD requestedAccess,
HCS_SYSTEM* computeSystem
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsOpenComputeSystemInNamespace(
[MarshalAs(UnmanagedType.LPWStr)] string idNamespace, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string id, // LPCWSTR
uint requestedAccess, // DWORD
IntPtr computeSystem // HCS_SYSTEM* out
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsOpenComputeSystemInNamespace(
<MarshalAs(UnmanagedType.LPWStr)> idNamespace As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> id As String, ' LPCWSTR
requestedAccess As UInteger, ' DWORD
computeSystem As IntPtr ' HCS_SYSTEM* out
) As Integer
End Function' idNamespace : LPCWSTR
' id : LPCWSTR
' requestedAccess : DWORD
' computeSystem : HCS_SYSTEM* out
Declare PtrSafe Function HcsOpenComputeSystemInNamespace Lib "computecore" ( _
ByVal idNamespace As LongPtr, _
ByVal id As LongPtr, _
ByVal requestedAccess As Long, _
ByVal computeSystem As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsOpenComputeSystemInNamespace = ctypes.windll.computecore.HcsOpenComputeSystemInNamespace
HcsOpenComputeSystemInNamespace.restype = ctypes.c_int
HcsOpenComputeSystemInNamespace.argtypes = [
wintypes.LPCWSTR, # idNamespace : LPCWSTR
wintypes.LPCWSTR, # id : LPCWSTR
wintypes.DWORD, # requestedAccess : DWORD
ctypes.c_void_p, # computeSystem : HCS_SYSTEM* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsOpenComputeSystemInNamespace = Fiddle::Function.new(
lib['HcsOpenComputeSystemInNamespace'],
[
Fiddle::TYPE_VOIDP, # idNamespace : LPCWSTR
Fiddle::TYPE_VOIDP, # id : LPCWSTR
-Fiddle::TYPE_INT, # requestedAccess : DWORD
Fiddle::TYPE_VOIDP, # computeSystem : HCS_SYSTEM* out
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsOpenComputeSystemInNamespace(
idNamespace: *const u16, // LPCWSTR
id: *const u16, // LPCWSTR
requestedAccess: u32, // DWORD
computeSystem: *mut *mut core::ffi::c_void // HCS_SYSTEM* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsOpenComputeSystemInNamespace([MarshalAs(UnmanagedType.LPWStr)] string idNamespace, [MarshalAs(UnmanagedType.LPWStr)] string id, uint requestedAccess, IntPtr computeSystem);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsOpenComputeSystemInNamespace' -Namespace Win32 -PassThru
# $api::HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)#uselib "computecore.dll"
#func global HcsOpenComputeSystemInNamespace "HcsOpenComputeSystemInNamespace" sptr, sptr, sptr, sptr
; HcsOpenComputeSystemInNamespace idNamespace, id, requestedAccess, computeSystem ; 戻り値は stat
; idNamespace : LPCWSTR -> "sptr"
; id : LPCWSTR -> "sptr"
; requestedAccess : DWORD -> "sptr"
; computeSystem : HCS_SYSTEM* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "computecore.dll"
#cfunc global HcsOpenComputeSystemInNamespace "HcsOpenComputeSystemInNamespace" wstr, wstr, int, sptr
; res = HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)
; idNamespace : LPCWSTR -> "wstr"
; id : LPCWSTR -> "wstr"
; requestedAccess : DWORD -> "int"
; computeSystem : HCS_SYSTEM* out -> "sptr"; HRESULT HcsOpenComputeSystemInNamespace(LPCWSTR idNamespace, LPCWSTR id, DWORD requestedAccess, HCS_SYSTEM* computeSystem)
#uselib "computecore.dll"
#cfunc global HcsOpenComputeSystemInNamespace "HcsOpenComputeSystemInNamespace" wstr, wstr, int, intptr
; res = HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)
; idNamespace : LPCWSTR -> "wstr"
; id : LPCWSTR -> "wstr"
; requestedAccess : DWORD -> "int"
; computeSystem : HCS_SYSTEM* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsOpenComputeSystemInNamespace = computecore.NewProc("HcsOpenComputeSystemInNamespace")
)
// idNamespace (LPCWSTR), id (LPCWSTR), requestedAccess (DWORD), computeSystem (HCS_SYSTEM* out)
r1, _, err := procHcsOpenComputeSystemInNamespace.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(idNamespace))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(id))),
uintptr(requestedAccess),
uintptr(computeSystem),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsOpenComputeSystemInNamespace(
idNamespace: PWideChar; // LPCWSTR
id: PWideChar; // LPCWSTR
requestedAccess: DWORD; // DWORD
computeSystem: Pointer // HCS_SYSTEM* out
): Integer; stdcall;
external 'computecore.dll' name 'HcsOpenComputeSystemInNamespace';result := DllCall("computecore\HcsOpenComputeSystemInNamespace"
, "WStr", idNamespace ; LPCWSTR
, "WStr", id ; LPCWSTR
, "UInt", requestedAccess ; DWORD
, "Ptr", computeSystem ; HCS_SYSTEM* out
, "Int") ; return: HRESULT●HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem) = DLL("computecore.dll", "int HcsOpenComputeSystemInNamespace(char*, char*, dword, void*)")
# 呼び出し: HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)
# idNamespace : LPCWSTR -> "char*"
# id : LPCWSTR -> "char*"
# requestedAccess : DWORD -> "dword"
# computeSystem : HCS_SYSTEM* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computecore" fn HcsOpenComputeSystemInNamespace(
idNamespace: [*c]const u16, // LPCWSTR
id: [*c]const u16, // LPCWSTR
requestedAccess: u32, // DWORD
computeSystem: ?*anyopaque // HCS_SYSTEM* out
) callconv(std.os.windows.WINAPI) i32;proc HcsOpenComputeSystemInNamespace(
idNamespace: WideCString, # LPCWSTR
id: WideCString, # LPCWSTR
requestedAccess: uint32, # DWORD
computeSystem: pointer # HCS_SYSTEM* out
): int32 {.importc: "HcsOpenComputeSystemInNamespace", stdcall, dynlib: "computecore.dll".}pragma(lib, "computecore");
extern(Windows)
int HcsOpenComputeSystemInNamespace(
const(wchar)* idNamespace, // LPCWSTR
const(wchar)* id, // LPCWSTR
uint requestedAccess, // DWORD
void* computeSystem // HCS_SYSTEM* out
);ccall((:HcsOpenComputeSystemInNamespace, "computecore.dll"), stdcall, Int32,
(Cwstring, Cwstring, UInt32, Ptr{Cvoid}),
idNamespace, id, requestedAccess, computeSystem)
# idNamespace : LPCWSTR -> Cwstring
# id : LPCWSTR -> Cwstring
# requestedAccess : DWORD -> UInt32
# computeSystem : HCS_SYSTEM* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsOpenComputeSystemInNamespace(
const uint16_t* idNamespace,
const uint16_t* id,
uint32_t requestedAccess,
void* computeSystem);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)
-- idNamespace : LPCWSTR
-- id : LPCWSTR
-- requestedAccess : DWORD
-- computeSystem : HCS_SYSTEM* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsOpenComputeSystemInNamespace = lib.func('__stdcall', 'HcsOpenComputeSystemInNamespace', 'int32_t', ['str16', 'str16', 'uint32_t', 'void *']);
// HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)
// idNamespace : LPCWSTR -> 'str16'
// id : LPCWSTR -> 'str16'
// requestedAccess : DWORD -> 'uint32_t'
// computeSystem : HCS_SYSTEM* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computecore.dll", {
HcsOpenComputeSystemInNamespace: { parameters: ["buffer", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem)
// idNamespace : LPCWSTR -> "buffer"
// id : LPCWSTR -> "buffer"
// requestedAccess : DWORD -> "u32"
// computeSystem : HCS_SYSTEM* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsOpenComputeSystemInNamespace(
const uint16_t* idNamespace,
const uint16_t* id,
uint32_t requestedAccess,
void* computeSystem);
C, "computecore.dll");
// $ffi->HcsOpenComputeSystemInNamespace(idNamespace, id, requestedAccess, computeSystem);
// idNamespace : LPCWSTR
// id : LPCWSTR
// requestedAccess : DWORD
// computeSystem : HCS_SYSTEM* 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 HcsOpenComputeSystemInNamespace(
WString idNamespace, // LPCWSTR
WString id, // LPCWSTR
int requestedAccess, // DWORD
Pointer computeSystem // HCS_SYSTEM* out
);
}@[Link("computecore")]
lib Libcomputecore
fun HcsOpenComputeSystemInNamespace = HcsOpenComputeSystemInNamespace(
idNamespace : UInt16*, # LPCWSTR
id : UInt16*, # LPCWSTR
requestedAccess : UInt32, # DWORD
computeSystem : Void* # HCS_SYSTEM* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HcsOpenComputeSystemInNamespaceNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Void>);
typedef HcsOpenComputeSystemInNamespaceDart = int Function(Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Void>);
final HcsOpenComputeSystemInNamespace = DynamicLibrary.open('computecore.dll')
.lookupFunction<HcsOpenComputeSystemInNamespaceNative, HcsOpenComputeSystemInNamespaceDart>('HcsOpenComputeSystemInNamespace');
// idNamespace : LPCWSTR -> Pointer<Utf16>
// id : LPCWSTR -> Pointer<Utf16>
// requestedAccess : DWORD -> Uint32
// computeSystem : HCS_SYSTEM* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsOpenComputeSystemInNamespace(
idNamespace: PWideChar; // LPCWSTR
id: PWideChar; // LPCWSTR
requestedAccess: DWORD; // DWORD
computeSystem: Pointer // HCS_SYSTEM* out
): Integer; stdcall;
external 'computecore.dll' name 'HcsOpenComputeSystemInNamespace';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsOpenComputeSystemInNamespace"
c_HcsOpenComputeSystemInNamespace :: CWString -> CWString -> Word32 -> Ptr () -> IO Int32
-- idNamespace : LPCWSTR -> CWString
-- id : LPCWSTR -> CWString
-- requestedAccess : DWORD -> Word32
-- computeSystem : HCS_SYSTEM* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcsopencomputesysteminnamespace =
foreign "HcsOpenComputeSystemInNamespace"
((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* idNamespace : LPCWSTR -> (ptr uint16_t) *)
(* id : LPCWSTR -> (ptr uint16_t) *)
(* requestedAccess : DWORD -> uint32_t *)
(* computeSystem : HCS_SYSTEM* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)
(cffi:defcfun ("HcsOpenComputeSystemInNamespace" hcs-open-compute-system-in-namespace :convention :stdcall) :int32
(id-namespace (:string :encoding :utf-16le)) ; LPCWSTR
(id (:string :encoding :utf-16le)) ; LPCWSTR
(requested-access :uint32) ; DWORD
(compute-system :pointer)) ; HCS_SYSTEM* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsOpenComputeSystemInNamespace = Win32::API::More->new('computecore',
'int HcsOpenComputeSystemInNamespace(LPCWSTR idNamespace, LPCWSTR id, DWORD requestedAccess, HANDLE computeSystem)');
# my $ret = $HcsOpenComputeSystemInNamespace->Call($idNamespace, $id, $requestedAccess, $computeSystem);
# idNamespace : LPCWSTR -> LPCWSTR
# id : LPCWSTR -> LPCWSTR
# requestedAccess : DWORD -> DWORD
# computeSystem : HCS_SYSTEM* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。