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