ホーム › System.ClrHosting › GetRequestedRuntimeVersionForCLSID
GetRequestedRuntimeVersionForCLSID
関数指定したCLSIDが要求するランタイムバージョンを取得する。
シグネチャ
// MSCorEE.dll
#include <windows.h>
HRESULT GetRequestedRuntimeVersionForCLSID(
const GUID* rclsid,
LPWSTR pVersion, // optional
DWORD cchBuffer,
DWORD* dwLength, // optional
CLSID_RESOLUTION_FLAGS dwResolutionFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| rclsid | GUID* | in | ランタイムバージョンを解決する対象コクラスの CLSID へのポインタ。 |
| pVersion | LPWSTR | outoptional | 解決されたバージョン文字列を受け取る出力バッファ。Unicode 文字列で返される。 |
| cchBuffer | DWORD | in | pVersion のサイズ。文字数で指定する。 |
| dwLength | DWORD* | outoptional | 実際に書き込まれた文字数を受け取る出力ポインタ。 |
| dwResolutionFlags | CLSID_RESOLUTION_FLAGS | in | 解決動作を制御する CLSID_RESOLUTION_FLAGS。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// MSCorEE.dll
#include <windows.h>
HRESULT GetRequestedRuntimeVersionForCLSID(
const GUID* rclsid,
LPWSTR pVersion, // optional
DWORD cchBuffer,
DWORD* dwLength, // optional
CLSID_RESOLUTION_FLAGS dwResolutionFlags
);[DllImport("MSCorEE.dll", ExactSpelling = true)]
static extern int GetRequestedRuntimeVersionForCLSID(
ref Guid rclsid, // GUID*
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pVersion, // LPWSTR optional, out
uint cchBuffer, // DWORD
IntPtr dwLength, // DWORD* optional, out
int dwResolutionFlags // CLSID_RESOLUTION_FLAGS
);<DllImport("MSCorEE.dll", ExactSpelling:=True)>
Public Shared Function GetRequestedRuntimeVersionForCLSID(
ByRef rclsid As Guid, ' GUID*
<MarshalAs(UnmanagedType.LPWStr)> pVersion As System.Text.StringBuilder, ' LPWSTR optional, out
cchBuffer As UInteger, ' DWORD
dwLength As IntPtr, ' DWORD* optional, out
dwResolutionFlags As Integer ' CLSID_RESOLUTION_FLAGS
) As Integer
End Function' rclsid : GUID*
' pVersion : LPWSTR optional, out
' cchBuffer : DWORD
' dwLength : DWORD* optional, out
' dwResolutionFlags : CLSID_RESOLUTION_FLAGS
Declare PtrSafe Function GetRequestedRuntimeVersionForCLSID Lib "mscoree" ( _
ByVal rclsid As LongPtr, _
ByVal pVersion As LongPtr, _
ByVal cchBuffer As Long, _
ByVal dwLength As LongPtr, _
ByVal dwResolutionFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetRequestedRuntimeVersionForCLSID = ctypes.windll.mscoree.GetRequestedRuntimeVersionForCLSID
GetRequestedRuntimeVersionForCLSID.restype = ctypes.c_int
GetRequestedRuntimeVersionForCLSID.argtypes = [
ctypes.c_void_p, # rclsid : GUID*
wintypes.LPWSTR, # pVersion : LPWSTR optional, out
wintypes.DWORD, # cchBuffer : DWORD
ctypes.POINTER(wintypes.DWORD), # dwLength : DWORD* optional, out
ctypes.c_int, # dwResolutionFlags : CLSID_RESOLUTION_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MSCorEE.dll')
GetRequestedRuntimeVersionForCLSID = Fiddle::Function.new(
lib['GetRequestedRuntimeVersionForCLSID'],
[
Fiddle::TYPE_VOIDP, # rclsid : GUID*
Fiddle::TYPE_VOIDP, # pVersion : LPWSTR optional, out
-Fiddle::TYPE_INT, # cchBuffer : DWORD
Fiddle::TYPE_VOIDP, # dwLength : DWORD* optional, out
Fiddle::TYPE_INT, # dwResolutionFlags : CLSID_RESOLUTION_FLAGS
],
Fiddle::TYPE_INT)#[link(name = "mscoree")]
extern "system" {
fn GetRequestedRuntimeVersionForCLSID(
rclsid: *const GUID, // GUID*
pVersion: *mut u16, // LPWSTR optional, out
cchBuffer: u32, // DWORD
dwLength: *mut u32, // DWORD* optional, out
dwResolutionFlags: i32 // CLSID_RESOLUTION_FLAGS
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MSCorEE.dll")]
public static extern int GetRequestedRuntimeVersionForCLSID(ref Guid rclsid, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pVersion, uint cchBuffer, IntPtr dwLength, int dwResolutionFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MSCorEE_GetRequestedRuntimeVersionForCLSID' -Namespace Win32 -PassThru
# $api::GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags)#uselib "MSCorEE.dll"
#func global GetRequestedRuntimeVersionForCLSID "GetRequestedRuntimeVersionForCLSID" sptr, sptr, sptr, sptr, sptr
; GetRequestedRuntimeVersionForCLSID varptr(rclsid), varptr(pVersion), cchBuffer, varptr(dwLength), dwResolutionFlags ; 戻り値は stat
; rclsid : GUID* -> "sptr"
; pVersion : LPWSTR optional, out -> "sptr"
; cchBuffer : DWORD -> "sptr"
; dwLength : DWORD* optional, out -> "sptr"
; dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MSCorEE.dll" #cfunc global GetRequestedRuntimeVersionForCLSID "GetRequestedRuntimeVersionForCLSID" var, var, int, var, int ; res = GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags) ; rclsid : GUID* -> "var" ; pVersion : LPWSTR optional, out -> "var" ; cchBuffer : DWORD -> "int" ; dwLength : DWORD* optional, out -> "var" ; dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MSCorEE.dll" #cfunc global GetRequestedRuntimeVersionForCLSID "GetRequestedRuntimeVersionForCLSID" sptr, sptr, int, sptr, int ; res = GetRequestedRuntimeVersionForCLSID(varptr(rclsid), varptr(pVersion), cchBuffer, varptr(dwLength), dwResolutionFlags) ; rclsid : GUID* -> "sptr" ; pVersion : LPWSTR optional, out -> "sptr" ; cchBuffer : DWORD -> "int" ; dwLength : DWORD* optional, out -> "sptr" ; dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetRequestedRuntimeVersionForCLSID(GUID* rclsid, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwLength, CLSID_RESOLUTION_FLAGS dwResolutionFlags) #uselib "MSCorEE.dll" #cfunc global GetRequestedRuntimeVersionForCLSID "GetRequestedRuntimeVersionForCLSID" var, var, int, var, int ; res = GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags) ; rclsid : GUID* -> "var" ; pVersion : LPWSTR optional, out -> "var" ; cchBuffer : DWORD -> "int" ; dwLength : DWORD* optional, out -> "var" ; dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetRequestedRuntimeVersionForCLSID(GUID* rclsid, LPWSTR pVersion, DWORD cchBuffer, DWORD* dwLength, CLSID_RESOLUTION_FLAGS dwResolutionFlags) #uselib "MSCorEE.dll" #cfunc global GetRequestedRuntimeVersionForCLSID "GetRequestedRuntimeVersionForCLSID" intptr, intptr, int, intptr, int ; res = GetRequestedRuntimeVersionForCLSID(varptr(rclsid), varptr(pVersion), cchBuffer, varptr(dwLength), dwResolutionFlags) ; rclsid : GUID* -> "intptr" ; pVersion : LPWSTR optional, out -> "intptr" ; cchBuffer : DWORD -> "int" ; dwLength : DWORD* optional, out -> "intptr" ; dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mscoree = windows.NewLazySystemDLL("MSCorEE.dll")
procGetRequestedRuntimeVersionForCLSID = mscoree.NewProc("GetRequestedRuntimeVersionForCLSID")
)
// rclsid (GUID*), pVersion (LPWSTR optional, out), cchBuffer (DWORD), dwLength (DWORD* optional, out), dwResolutionFlags (CLSID_RESOLUTION_FLAGS)
r1, _, err := procGetRequestedRuntimeVersionForCLSID.Call(
uintptr(rclsid),
uintptr(pVersion),
uintptr(cchBuffer),
uintptr(dwLength),
uintptr(dwResolutionFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetRequestedRuntimeVersionForCLSID(
rclsid: PGUID; // GUID*
pVersion: PWideChar; // LPWSTR optional, out
cchBuffer: DWORD; // DWORD
dwLength: Pointer; // DWORD* optional, out
dwResolutionFlags: Integer // CLSID_RESOLUTION_FLAGS
): Integer; stdcall;
external 'MSCorEE.dll' name 'GetRequestedRuntimeVersionForCLSID';result := DllCall("MSCorEE\GetRequestedRuntimeVersionForCLSID"
, "Ptr", rclsid ; GUID*
, "Ptr", pVersion ; LPWSTR optional, out
, "UInt", cchBuffer ; DWORD
, "Ptr", dwLength ; DWORD* optional, out
, "Int", dwResolutionFlags ; CLSID_RESOLUTION_FLAGS
, "Int") ; return: HRESULT●GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags) = DLL("MSCorEE.dll", "int GetRequestedRuntimeVersionForCLSID(void*, char*, dword, void*, int)")
# 呼び出し: GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags)
# rclsid : GUID* -> "void*"
# pVersion : LPWSTR optional, out -> "char*"
# cchBuffer : DWORD -> "dword"
# dwLength : DWORD* optional, out -> "void*"
# dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mscoree" fn GetRequestedRuntimeVersionForCLSID(
rclsid: [*c]GUID, // GUID*
pVersion: [*c]u16, // LPWSTR optional, out
cchBuffer: u32, // DWORD
dwLength: [*c]u32, // DWORD* optional, out
dwResolutionFlags: i32 // CLSID_RESOLUTION_FLAGS
) callconv(std.os.windows.WINAPI) i32;proc GetRequestedRuntimeVersionForCLSID(
rclsid: ptr GUID, # GUID*
pVersion: ptr uint16, # LPWSTR optional, out
cchBuffer: uint32, # DWORD
dwLength: ptr uint32, # DWORD* optional, out
dwResolutionFlags: int32 # CLSID_RESOLUTION_FLAGS
): int32 {.importc: "GetRequestedRuntimeVersionForCLSID", stdcall, dynlib: "MSCorEE.dll".}pragma(lib, "mscoree");
extern(Windows)
int GetRequestedRuntimeVersionForCLSID(
GUID* rclsid, // GUID*
wchar* pVersion, // LPWSTR optional, out
uint cchBuffer, // DWORD
uint* dwLength, // DWORD* optional, out
int dwResolutionFlags // CLSID_RESOLUTION_FLAGS
);ccall((:GetRequestedRuntimeVersionForCLSID, "MSCorEE.dll"), stdcall, Int32,
(Ptr{GUID}, Ptr{UInt16}, UInt32, Ptr{UInt32}, Int32),
rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags)
# rclsid : GUID* -> Ptr{GUID}
# pVersion : LPWSTR optional, out -> Ptr{UInt16}
# cchBuffer : DWORD -> UInt32
# dwLength : DWORD* optional, out -> Ptr{UInt32}
# dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetRequestedRuntimeVersionForCLSID(
void* rclsid,
uint16_t* pVersion,
uint32_t cchBuffer,
uint32_t* dwLength,
int32_t dwResolutionFlags);
]]
local mscoree = ffi.load("mscoree")
-- mscoree.GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags)
-- rclsid : GUID*
-- pVersion : LPWSTR optional, out
-- cchBuffer : DWORD
-- dwLength : DWORD* optional, out
-- dwResolutionFlags : CLSID_RESOLUTION_FLAGS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MSCorEE.dll');
const GetRequestedRuntimeVersionForCLSID = lib.func('__stdcall', 'GetRequestedRuntimeVersionForCLSID', 'int32_t', ['void *', 'uint16_t *', 'uint32_t', 'uint32_t *', 'int32_t']);
// GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags)
// rclsid : GUID* -> 'void *'
// pVersion : LPWSTR optional, out -> 'uint16_t *'
// cchBuffer : DWORD -> 'uint32_t'
// dwLength : DWORD* optional, out -> 'uint32_t *'
// dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MSCorEE.dll", {
GetRequestedRuntimeVersionForCLSID: { parameters: ["pointer", "buffer", "u32", "pointer", "i32"], result: "i32" },
});
// lib.symbols.GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags)
// rclsid : GUID* -> "pointer"
// pVersion : LPWSTR optional, out -> "buffer"
// cchBuffer : DWORD -> "u32"
// dwLength : DWORD* optional, out -> "pointer"
// dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetRequestedRuntimeVersionForCLSID(
void* rclsid,
uint16_t* pVersion,
uint32_t cchBuffer,
uint32_t* dwLength,
int32_t dwResolutionFlags);
C, "MSCorEE.dll");
// $ffi->GetRequestedRuntimeVersionForCLSID(rclsid, pVersion, cchBuffer, dwLength, dwResolutionFlags);
// rclsid : GUID*
// pVersion : LPWSTR optional, out
// cchBuffer : DWORD
// dwLength : DWORD* optional, out
// dwResolutionFlags : CLSID_RESOLUTION_FLAGS
// 構造体/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 Mscoree extends StdCallLibrary {
Mscoree INSTANCE = Native.load("mscoree", Mscoree.class);
int GetRequestedRuntimeVersionForCLSID(
Pointer rclsid, // GUID*
char[] pVersion, // LPWSTR optional, out
int cchBuffer, // DWORD
IntByReference dwLength, // DWORD* optional, out
int dwResolutionFlags // CLSID_RESOLUTION_FLAGS
);
}@[Link("mscoree")]
lib LibMSCorEE
fun GetRequestedRuntimeVersionForCLSID = GetRequestedRuntimeVersionForCLSID(
rclsid : GUID*, # GUID*
pVersion : UInt16*, # LPWSTR optional, out
cchBuffer : UInt32, # DWORD
dwLength : UInt32*, # DWORD* optional, out
dwResolutionFlags : Int32 # CLSID_RESOLUTION_FLAGS
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetRequestedRuntimeVersionForCLSIDNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Pointer<Uint32>, Int32);
typedef GetRequestedRuntimeVersionForCLSIDDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Uint32>, int);
final GetRequestedRuntimeVersionForCLSID = DynamicLibrary.open('MSCorEE.dll')
.lookupFunction<GetRequestedRuntimeVersionForCLSIDNative, GetRequestedRuntimeVersionForCLSIDDart>('GetRequestedRuntimeVersionForCLSID');
// rclsid : GUID* -> Pointer<Void>
// pVersion : LPWSTR optional, out -> Pointer<Utf16>
// cchBuffer : DWORD -> Uint32
// dwLength : DWORD* optional, out -> Pointer<Uint32>
// dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetRequestedRuntimeVersionForCLSID(
rclsid: PGUID; // GUID*
pVersion: PWideChar; // LPWSTR optional, out
cchBuffer: DWORD; // DWORD
dwLength: Pointer; // DWORD* optional, out
dwResolutionFlags: Integer // CLSID_RESOLUTION_FLAGS
): Integer; stdcall;
external 'MSCorEE.dll' name 'GetRequestedRuntimeVersionForCLSID';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetRequestedRuntimeVersionForCLSID"
c_GetRequestedRuntimeVersionForCLSID :: Ptr () -> CWString -> Word32 -> Ptr Word32 -> Int32 -> IO Int32
-- rclsid : GUID* -> Ptr ()
-- pVersion : LPWSTR optional, out -> CWString
-- cchBuffer : DWORD -> Word32
-- dwLength : DWORD* optional, out -> Ptr Word32
-- dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getrequestedruntimeversionforclsid =
foreign "GetRequestedRuntimeVersionForCLSID"
((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> (ptr uint32_t) @-> int32_t @-> returning int32_t)
(* rclsid : GUID* -> (ptr void) *)
(* pVersion : LPWSTR optional, out -> (ptr uint16_t) *)
(* cchBuffer : DWORD -> uint32_t *)
(* dwLength : DWORD* optional, out -> (ptr uint32_t) *)
(* dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mscoree (t "MSCorEE.dll"))
(cffi:use-foreign-library mscoree)
(cffi:defcfun ("GetRequestedRuntimeVersionForCLSID" get-requested-runtime-version-for-clsid :convention :stdcall) :int32
(rclsid :pointer) ; GUID*
(p-version :pointer) ; LPWSTR optional, out
(cch-buffer :uint32) ; DWORD
(dw-length :pointer) ; DWORD* optional, out
(dw-resolution-flags :int32)) ; CLSID_RESOLUTION_FLAGS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetRequestedRuntimeVersionForCLSID = Win32::API::More->new('MSCorEE',
'int GetRequestedRuntimeVersionForCLSID(LPVOID rclsid, LPWSTR pVersion, DWORD cchBuffer, LPVOID dwLength, int dwResolutionFlags)');
# my $ret = $GetRequestedRuntimeVersionForCLSID->Call($rclsid, $pVersion, $cchBuffer, $dwLength, $dwResolutionFlags);
# rclsid : GUID* -> LPVOID
# pVersion : LPWSTR optional, out -> LPWSTR
# cchBuffer : DWORD -> DWORD
# dwLength : DWORD* optional, out -> LPVOID
# dwResolutionFlags : CLSID_RESOLUTION_FLAGS -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。