ホーム › System.HostComputeSystem › HcsSetOperationContext
HcsSetOperationContext
関数HCS操作にコンテキストを設定する。
シグネチャ
// computecore.dll
#include <windows.h>
HRESULT HcsSetOperationContext(
HCS_OPERATION operation,
const void* context // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| operation | HCS_OPERATION | in | コンテキストを設定する対象のHCS操作ハンドル。 |
| context | void* | inoptional | 操作に新たに関連付ける任意のユーザー定義データ。NULL可。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// computecore.dll
#include <windows.h>
HRESULT HcsSetOperationContext(
HCS_OPERATION operation,
const void* context // optional
);[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsSetOperationContext(
IntPtr operation, // HCS_OPERATION
IntPtr context // void* optional
);<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsSetOperationContext(
operation As IntPtr, ' HCS_OPERATION
context As IntPtr ' void* optional
) As Integer
End Function' operation : HCS_OPERATION
' context : void* optional
Declare PtrSafe Function HcsSetOperationContext Lib "computecore" ( _
ByVal operation As LongPtr, _
ByVal context As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
HcsSetOperationContext = ctypes.windll.computecore.HcsSetOperationContext
HcsSetOperationContext.restype = ctypes.c_int
HcsSetOperationContext.argtypes = [
wintypes.HANDLE, # operation : HCS_OPERATION
ctypes.POINTER(None), # context : void* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('computecore.dll')
HcsSetOperationContext = Fiddle::Function.new(
lib['HcsSetOperationContext'],
[
Fiddle::TYPE_VOIDP, # operation : HCS_OPERATION
Fiddle::TYPE_VOIDP, # context : void* optional
],
Fiddle::TYPE_INT)#[link(name = "computecore")]
extern "system" {
fn HcsSetOperationContext(
operation: *mut core::ffi::c_void, // HCS_OPERATION
context: *const () // void* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsSetOperationContext(IntPtr operation, IntPtr context);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsSetOperationContext' -Namespace Win32 -PassThru
# $api::HcsSetOperationContext(operation, context)#uselib "computecore.dll"
#func global HcsSetOperationContext "HcsSetOperationContext" sptr, sptr
; HcsSetOperationContext operation, context ; 戻り値は stat
; operation : HCS_OPERATION -> "sptr"
; context : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "computecore.dll"
#cfunc global HcsSetOperationContext "HcsSetOperationContext" sptr, sptr
; res = HcsSetOperationContext(operation, context)
; operation : HCS_OPERATION -> "sptr"
; context : void* optional -> "sptr"; HRESULT HcsSetOperationContext(HCS_OPERATION operation, void* context)
#uselib "computecore.dll"
#cfunc global HcsSetOperationContext "HcsSetOperationContext" intptr, intptr
; res = HcsSetOperationContext(operation, context)
; operation : HCS_OPERATION -> "intptr"
; context : void* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
computecore = windows.NewLazySystemDLL("computecore.dll")
procHcsSetOperationContext = computecore.NewProc("HcsSetOperationContext")
)
// operation (HCS_OPERATION), context (void* optional)
r1, _, err := procHcsSetOperationContext.Call(
uintptr(operation),
uintptr(context),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction HcsSetOperationContext(
operation: THandle; // HCS_OPERATION
context: Pointer // void* optional
): Integer; stdcall;
external 'computecore.dll' name 'HcsSetOperationContext';result := DllCall("computecore\HcsSetOperationContext"
, "Ptr", operation ; HCS_OPERATION
, "Ptr", context ; void* optional
, "Int") ; return: HRESULT●HcsSetOperationContext(operation, context) = DLL("computecore.dll", "int HcsSetOperationContext(void*, void*)")
# 呼び出し: HcsSetOperationContext(operation, context)
# operation : HCS_OPERATION -> "void*"
# context : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "computecore" fn HcsSetOperationContext(
operation: ?*anyopaque, // HCS_OPERATION
context: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) i32;proc HcsSetOperationContext(
operation: pointer, # HCS_OPERATION
context: pointer # void* optional
): int32 {.importc: "HcsSetOperationContext", stdcall, dynlib: "computecore.dll".}pragma(lib, "computecore");
extern(Windows)
int HcsSetOperationContext(
void* operation, // HCS_OPERATION
void* context // void* optional
);ccall((:HcsSetOperationContext, "computecore.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}),
operation, context)
# operation : HCS_OPERATION -> Ptr{Cvoid}
# context : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t HcsSetOperationContext(
void* operation,
void* context);
]]
local computecore = ffi.load("computecore")
-- computecore.HcsSetOperationContext(operation, context)
-- operation : HCS_OPERATION
-- context : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('computecore.dll');
const HcsSetOperationContext = lib.func('__stdcall', 'HcsSetOperationContext', 'int32_t', ['void *', 'void *']);
// HcsSetOperationContext(operation, context)
// operation : HCS_OPERATION -> 'void *'
// context : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("computecore.dll", {
HcsSetOperationContext: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.HcsSetOperationContext(operation, context)
// operation : HCS_OPERATION -> "pointer"
// context : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t HcsSetOperationContext(
void* operation,
void* context);
C, "computecore.dll");
// $ffi->HcsSetOperationContext(operation, context);
// operation : HCS_OPERATION
// context : void* 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 HcsSetOperationContext(
Pointer operation, // HCS_OPERATION
Pointer context // void* optional
);
}@[Link("computecore")]
lib Libcomputecore
fun HcsSetOperationContext = HcsSetOperationContext(
operation : Void*, # HCS_OPERATION
context : Void* # void* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef HcsSetOperationContextNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef HcsSetOperationContextDart = int Function(Pointer<Void>, Pointer<Void>);
final HcsSetOperationContext = DynamicLibrary.open('computecore.dll')
.lookupFunction<HcsSetOperationContextNative, HcsSetOperationContextDart>('HcsSetOperationContext');
// operation : HCS_OPERATION -> Pointer<Void>
// context : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function HcsSetOperationContext(
operation: THandle; // HCS_OPERATION
context: Pointer // void* optional
): Integer; stdcall;
external 'computecore.dll' name 'HcsSetOperationContext';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "HcsSetOperationContext"
c_HcsSetOperationContext :: Ptr () -> Ptr () -> IO Int32
-- operation : HCS_OPERATION -> Ptr ()
-- context : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let hcssetoperationcontext =
foreign "HcsSetOperationContext"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* operation : HCS_OPERATION -> (ptr void) *)
(* context : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)
(cffi:defcfun ("HcsSetOperationContext" hcs-set-operation-context :convention :stdcall) :int32
(operation :pointer) ; HCS_OPERATION
(context :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $HcsSetOperationContext = Win32::API::More->new('computecore',
'int HcsSetOperationContext(HANDLE operation, LPVOID context)');
# my $ret = $HcsSetOperationContext->Call($operation, $context);
# operation : HCS_OPERATION -> HANDLE
# context : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。