ホーム › System.ClrHosting › CorBindToCurrentRuntime
CorBindToCurrentRuntime
関数構成ファイルに従って現在のCLRランタイムにバインドする。
シグネチャ
// MSCorEE.dll
#include <windows.h>
HRESULT CorBindToCurrentRuntime(
LPCWSTR pwszFileName,
const GUID* rclsid,
const GUID* riid,
void** ppv
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pwszFileName | LPCWSTR | in |
| rclsid | GUID* | in |
| riid | GUID* | in |
| ppv | void** | inout |
戻り値の型: HRESULT
各言語での呼び出し定義
// MSCorEE.dll
#include <windows.h>
HRESULT CorBindToCurrentRuntime(
LPCWSTR pwszFileName,
const GUID* rclsid,
const GUID* riid,
void** ppv
);[DllImport("MSCorEE.dll", ExactSpelling = true)]
static extern int CorBindToCurrentRuntime(
[MarshalAs(UnmanagedType.LPWStr)] string pwszFileName, // LPCWSTR
ref Guid rclsid, // GUID*
ref Guid riid, // GUID*
IntPtr ppv // void** in/out
);<DllImport("MSCorEE.dll", ExactSpelling:=True)>
Public Shared Function CorBindToCurrentRuntime(
<MarshalAs(UnmanagedType.LPWStr)> pwszFileName As String, ' LPCWSTR
ByRef rclsid As Guid, ' GUID*
ByRef riid As Guid, ' GUID*
ppv As IntPtr ' void** in/out
) As Integer
End Function' pwszFileName : LPCWSTR
' rclsid : GUID*
' riid : GUID*
' ppv : void** in/out
Declare PtrSafe Function CorBindToCurrentRuntime Lib "mscoree" ( _
ByVal pwszFileName As LongPtr, _
ByVal rclsid As LongPtr, _
ByVal riid As LongPtr, _
ByVal ppv As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CorBindToCurrentRuntime = ctypes.windll.mscoree.CorBindToCurrentRuntime
CorBindToCurrentRuntime.restype = ctypes.c_int
CorBindToCurrentRuntime.argtypes = [
wintypes.LPCWSTR, # pwszFileName : LPCWSTR
ctypes.c_void_p, # rclsid : GUID*
ctypes.c_void_p, # riid : GUID*
ctypes.c_void_p, # ppv : void** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSCorEE.dll')
CorBindToCurrentRuntime = Fiddle::Function.new(
lib['CorBindToCurrentRuntime'],
[
Fiddle::TYPE_VOIDP, # pwszFileName : LPCWSTR
Fiddle::TYPE_VOIDP, # rclsid : GUID*
Fiddle::TYPE_VOIDP, # riid : GUID*
Fiddle::TYPE_VOIDP, # ppv : void** in/out
],
Fiddle::TYPE_INT)#[link(name = "mscoree")]
extern "system" {
fn CorBindToCurrentRuntime(
pwszFileName: *const u16, // LPCWSTR
rclsid: *const GUID, // GUID*
riid: *const GUID, // GUID*
ppv: *mut *mut () // void** in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSCorEE.dll")]
public static extern int CorBindToCurrentRuntime([MarshalAs(UnmanagedType.LPWStr)] string pwszFileName, ref Guid rclsid, ref Guid riid, IntPtr ppv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSCorEE_CorBindToCurrentRuntime' -Namespace Win32 -PassThru
# $api::CorBindToCurrentRuntime(pwszFileName, rclsid, riid, ppv)#uselib "MSCorEE.dll"
#func global CorBindToCurrentRuntime "CorBindToCurrentRuntime" sptr, sptr, sptr, sptr
; CorBindToCurrentRuntime pwszFileName, varptr(rclsid), varptr(riid), ppv ; 戻り値は stat
; pwszFileName : LPCWSTR -> "sptr"
; rclsid : GUID* -> "sptr"
; riid : GUID* -> "sptr"
; ppv : void** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSCorEE.dll" #cfunc global CorBindToCurrentRuntime "CorBindToCurrentRuntime" wstr, var, var, sptr ; res = CorBindToCurrentRuntime(pwszFileName, rclsid, riid, ppv) ; pwszFileName : LPCWSTR -> "wstr" ; rclsid : GUID* -> "var" ; riid : GUID* -> "var" ; ppv : void** in/out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSCorEE.dll" #cfunc global CorBindToCurrentRuntime "CorBindToCurrentRuntime" wstr, sptr, sptr, sptr ; res = CorBindToCurrentRuntime(pwszFileName, varptr(rclsid), varptr(riid), ppv) ; pwszFileName : LPCWSTR -> "wstr" ; rclsid : GUID* -> "sptr" ; riid : GUID* -> "sptr" ; ppv : void** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CorBindToCurrentRuntime(LPCWSTR pwszFileName, GUID* rclsid, GUID* riid, void** ppv) #uselib "MSCorEE.dll" #cfunc global CorBindToCurrentRuntime "CorBindToCurrentRuntime" wstr, var, var, intptr ; res = CorBindToCurrentRuntime(pwszFileName, rclsid, riid, ppv) ; pwszFileName : LPCWSTR -> "wstr" ; rclsid : GUID* -> "var" ; riid : GUID* -> "var" ; ppv : void** in/out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CorBindToCurrentRuntime(LPCWSTR pwszFileName, GUID* rclsid, GUID* riid, void** ppv) #uselib "MSCorEE.dll" #cfunc global CorBindToCurrentRuntime "CorBindToCurrentRuntime" wstr, intptr, intptr, intptr ; res = CorBindToCurrentRuntime(pwszFileName, varptr(rclsid), varptr(riid), ppv) ; pwszFileName : LPCWSTR -> "wstr" ; rclsid : GUID* -> "intptr" ; riid : GUID* -> "intptr" ; ppv : void** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscoree = windows.NewLazySystemDLL("MSCorEE.dll")
procCorBindToCurrentRuntime = mscoree.NewProc("CorBindToCurrentRuntime")
)
// pwszFileName (LPCWSTR), rclsid (GUID*), riid (GUID*), ppv (void** in/out)
r1, _, err := procCorBindToCurrentRuntime.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszFileName))),
uintptr(rclsid),
uintptr(riid),
uintptr(ppv),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CorBindToCurrentRuntime(
pwszFileName: PWideChar; // LPCWSTR
rclsid: PGUID; // GUID*
riid: PGUID; // GUID*
ppv: Pointer // void** in/out
): Integer; stdcall;
external 'MSCorEE.dll' name 'CorBindToCurrentRuntime';result := DllCall("MSCorEE\CorBindToCurrentRuntime"
, "WStr", pwszFileName ; LPCWSTR
, "Ptr", rclsid ; GUID*
, "Ptr", riid ; GUID*
, "Ptr", ppv ; void** in/out
, "Int") ; return: HRESULT●CorBindToCurrentRuntime(pwszFileName, rclsid, riid, ppv) = DLL("MSCorEE.dll", "int CorBindToCurrentRuntime(char*, void*, void*, void*)")
# 呼び出し: CorBindToCurrentRuntime(pwszFileName, rclsid, riid, ppv)
# pwszFileName : LPCWSTR -> "char*"
# rclsid : GUID* -> "void*"
# riid : GUID* -> "void*"
# ppv : void** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。