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

HcsAddResourceToOperation

関数
HCS操作にハンドル等のリソースを追加する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsAddResourceToOperation(
    HCS_OPERATION operation,
    HCS_RESOURCE_TYPE type,
    LPCWSTR uri,
    HANDLE handle
);

パラメーター

名前方向
operationHCS_OPERATIONin
typeHCS_RESOURCE_TYPEin
uriLPCWSTRin
handleHANDLEin

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

HcsAddResourceToOperation = ctypes.windll.computecore.HcsAddResourceToOperation
HcsAddResourceToOperation.restype = ctypes.c_int
HcsAddResourceToOperation.argtypes = [
    wintypes.HANDLE,  # operation : HCS_OPERATION
    ctypes.c_int,  # type : HCS_RESOURCE_TYPE
    wintypes.LPCWSTR,  # uri : LPCWSTR
    wintypes.HANDLE,  # handle : HANDLE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsAddResourceToOperation = computecore.NewProc("HcsAddResourceToOperation")
)

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