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