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

HcsCreateOperationWithNotifications

関数
通知付きのHCS操作を作成する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HCS_OPERATION HcsCreateOperationWithNotifications(
    HCS_OPERATION_OPTIONS eventTypes,
    const void* context,   // optional
    HCS_EVENT_CALLBACK callback
);

パラメーター

名前方向説明
eventTypesHCS_OPERATION_OPTIONSin操作で受け取る通知イベント種別を示す列挙オプション。
contextvoid*inoptional操作に関連付ける任意のユーザー定義データ。NULL可。
callbackHCS_EVENT_CALLBACKinイベント発生時に呼ばれるコールバック関数。

戻り値の型: HCS_OPERATION

各言語での呼び出し定義

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

HCS_OPERATION HcsCreateOperationWithNotifications(
    HCS_OPERATION_OPTIONS eventTypes,
    const void* context,   // optional
    HCS_EVENT_CALLBACK callback
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern IntPtr HcsCreateOperationWithNotifications(
    int eventTypes,   // HCS_OPERATION_OPTIONS
    IntPtr context,   // void* optional
    IntPtr callback   // HCS_EVENT_CALLBACK
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsCreateOperationWithNotifications(
    eventTypes As Integer,   ' HCS_OPERATION_OPTIONS
    context As IntPtr,   ' void* optional
    callback As IntPtr   ' HCS_EVENT_CALLBACK
) As IntPtr
End Function
' eventTypes : HCS_OPERATION_OPTIONS
' context : void* optional
' callback : HCS_EVENT_CALLBACK
Declare PtrSafe Function HcsCreateOperationWithNotifications Lib "computecore" ( _
    ByVal eventTypes As Long, _
    ByVal context As LongPtr, _
    ByVal callback As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HcsCreateOperationWithNotifications = ctypes.windll.computecore.HcsCreateOperationWithNotifications
HcsCreateOperationWithNotifications.restype = ctypes.c_void_p
HcsCreateOperationWithNotifications.argtypes = [
    ctypes.c_int,  # eventTypes : HCS_OPERATION_OPTIONS
    ctypes.POINTER(None),  # context : void* optional
    ctypes.c_void_p,  # callback : HCS_EVENT_CALLBACK
]
require 'fiddle'
require 'fiddle/import'

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

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsCreateOperationWithNotifications = computecore.NewProc("HcsCreateOperationWithNotifications")
)

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

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

typedef HcsCreateOperationWithNotificationsNative = Pointer<Void> Function(Int32, Pointer<Void>, Pointer<Void>);
typedef HcsCreateOperationWithNotificationsDart = Pointer<Void> Function(int, Pointer<Void>, Pointer<Void>);
final HcsCreateOperationWithNotifications = DynamicLibrary.open('computecore.dll')
    .lookupFunction<HcsCreateOperationWithNotificationsNative, HcsCreateOperationWithNotificationsDart>('HcsCreateOperationWithNotifications');
// eventTypes : HCS_OPERATION_OPTIONS -> Int32
// context : void* optional -> Pointer<Void>
// callback : HCS_EVENT_CALLBACK -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function HcsCreateOperationWithNotifications(
  eventTypes: Integer;   // HCS_OPERATION_OPTIONS
  context: Pointer;   // void* optional
  callback: Pointer   // HCS_EVENT_CALLBACK
): THandle; stdcall;
  external 'computecore.dll' name 'HcsCreateOperationWithNotifications';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "HcsCreateOperationWithNotifications"
  c_HcsCreateOperationWithNotifications :: Int32 -> Ptr () -> Ptr () -> IO (Ptr ())
-- eventTypes : HCS_OPERATION_OPTIONS -> Int32
-- context : void* optional -> Ptr ()
-- callback : HCS_EVENT_CALLBACK -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let hcscreateoperationwithnotifications =
  foreign "HcsCreateOperationWithNotifications"
    (int32_t @-> (ptr void) @-> (ptr void) @-> returning (ptr void))
(* eventTypes : HCS_OPERATION_OPTIONS -> int32_t *)
(* context : void* optional -> (ptr void) *)
(* callback : HCS_EVENT_CALLBACK -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library computecore (t "computecore.dll"))
(cffi:use-foreign-library computecore)

(cffi:defcfun ("HcsCreateOperationWithNotifications" hcs-create-operation-with-notifications :convention :stdcall) :pointer
  (event-types :int32)   ; HCS_OPERATION_OPTIONS
  (context :pointer)   ; void* optional
  (callback :pointer))   ; HCS_EVENT_CALLBACK
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $HcsCreateOperationWithNotifications = Win32::API::More->new('computecore',
    'HANDLE HcsCreateOperationWithNotifications(int eventTypes, LPVOID context, LPVOID callback)');
# my $ret = $HcsCreateOperationWithNotifications->Call($eventTypes, $context, $callback);
# eventTypes : HCS_OPERATION_OPTIONS -> int
# context : void* optional -> LPVOID
# callback : HCS_EVENT_CALLBACK -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

使用する型