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

LoadRegTypeLib

関数
GUIDとバージョンで登録済みタイプライブラリを検索して読み込む。
DLLOLEAUT32.dll呼出規約winapi

シグネチャ

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

HRESULT LoadRegTypeLib(
    const GUID* rguid,
    WORD wVerMajor,
    WORD wVerMinor,
    DWORD lcid,
    ITypeLib** pptlib
);

パラメーター

名前方向
rguidGUID*in
wVerMajorWORDin
wVerMinorWORDin
lcidDWORDin
pptlibITypeLib**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT LoadRegTypeLib(
    const GUID* rguid,
    WORD wVerMajor,
    WORD wVerMinor,
    DWORD lcid,
    ITypeLib** pptlib
);
[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int LoadRegTypeLib(
    ref Guid rguid,   // GUID*
    ushort wVerMajor,   // WORD
    ushort wVerMinor,   // WORD
    uint lcid,   // DWORD
    IntPtr pptlib   // ITypeLib** out
);
<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function LoadRegTypeLib(
    ByRef rguid As Guid,   ' GUID*
    wVerMajor As UShort,   ' WORD
    wVerMinor As UShort,   ' WORD
    lcid As UInteger,   ' DWORD
    pptlib As IntPtr   ' ITypeLib** out
) As Integer
End Function
' rguid : GUID*
' wVerMajor : WORD
' wVerMinor : WORD
' lcid : DWORD
' pptlib : ITypeLib** out
Declare PtrSafe Function LoadRegTypeLib Lib "oleaut32" ( _
    ByVal rguid As LongPtr, _
    ByVal wVerMajor As Integer, _
    ByVal wVerMinor As Integer, _
    ByVal lcid As Long, _
    ByVal pptlib As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

LoadRegTypeLib = ctypes.windll.oleaut32.LoadRegTypeLib
LoadRegTypeLib.restype = ctypes.c_int
LoadRegTypeLib.argtypes = [
    ctypes.c_void_p,  # rguid : GUID*
    ctypes.c_ushort,  # wVerMajor : WORD
    ctypes.c_ushort,  # wVerMinor : WORD
    wintypes.DWORD,  # lcid : DWORD
    ctypes.c_void_p,  # pptlib : ITypeLib** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OLEAUT32.dll')
LoadRegTypeLib = Fiddle::Function.new(
  lib['LoadRegTypeLib'],
  [
    Fiddle::TYPE_VOIDP,  # rguid : GUID*
    -Fiddle::TYPE_SHORT,  # wVerMajor : WORD
    -Fiddle::TYPE_SHORT,  # wVerMinor : WORD
    -Fiddle::TYPE_INT,  # lcid : DWORD
    Fiddle::TYPE_VOIDP,  # pptlib : ITypeLib** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "oleaut32")]
extern "system" {
    fn LoadRegTypeLib(
        rguid: *const GUID,  // GUID*
        wVerMajor: u16,  // WORD
        wVerMinor: u16,  // WORD
        lcid: u32,  // DWORD
        pptlib: *mut *mut core::ffi::c_void  // ITypeLib** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int LoadRegTypeLib(ref Guid rguid, ushort wVerMajor, ushort wVerMinor, uint lcid, IntPtr pptlib);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_LoadRegTypeLib' -Namespace Win32 -PassThru
# $api::LoadRegTypeLib(rguid, wVerMajor, wVerMinor, lcid, pptlib)
#uselib "OLEAUT32.dll"
#func global LoadRegTypeLib "LoadRegTypeLib" sptr, sptr, sptr, sptr, sptr
; LoadRegTypeLib varptr(rguid), wVerMajor, wVerMinor, lcid, pptlib   ; 戻り値は stat
; rguid : GUID* -> "sptr"
; wVerMajor : WORD -> "sptr"
; wVerMinor : WORD -> "sptr"
; lcid : DWORD -> "sptr"
; pptlib : ITypeLib** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "OLEAUT32.dll"
#cfunc global LoadRegTypeLib "LoadRegTypeLib" var, int, int, int, sptr
; res = LoadRegTypeLib(rguid, wVerMajor, wVerMinor, lcid, pptlib)
; rguid : GUID* -> "var"
; wVerMajor : WORD -> "int"
; wVerMinor : WORD -> "int"
; lcid : DWORD -> "int"
; pptlib : ITypeLib** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT LoadRegTypeLib(GUID* rguid, WORD wVerMajor, WORD wVerMinor, DWORD lcid, ITypeLib** pptlib)
#uselib "OLEAUT32.dll"
#cfunc global LoadRegTypeLib "LoadRegTypeLib" var, int, int, int, intptr
; res = LoadRegTypeLib(rguid, wVerMajor, wVerMinor, lcid, pptlib)
; rguid : GUID* -> "var"
; wVerMajor : WORD -> "int"
; wVerMinor : WORD -> "int"
; lcid : DWORD -> "int"
; pptlib : ITypeLib** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
	procLoadRegTypeLib = oleaut32.NewProc("LoadRegTypeLib")
)

// rguid (GUID*), wVerMajor (WORD), wVerMinor (WORD), lcid (DWORD), pptlib (ITypeLib** out)
r1, _, err := procLoadRegTypeLib.Call(
	uintptr(rguid),
	uintptr(wVerMajor),
	uintptr(wVerMinor),
	uintptr(lcid),
	uintptr(pptlib),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function LoadRegTypeLib(
  rguid: PGUID;   // GUID*
  wVerMajor: Word;   // WORD
  wVerMinor: Word;   // WORD
  lcid: DWORD;   // DWORD
  pptlib: Pointer   // ITypeLib** out
): Integer; stdcall;
  external 'OLEAUT32.dll' name 'LoadRegTypeLib';
result := DllCall("OLEAUT32\LoadRegTypeLib"
    , "Ptr", rguid   ; GUID*
    , "UShort", wVerMajor   ; WORD
    , "UShort", wVerMinor   ; WORD
    , "UInt", lcid   ; DWORD
    , "Ptr", pptlib   ; ITypeLib** out
    , "Int")   ; return: HRESULT
●LoadRegTypeLib(rguid, wVerMajor, wVerMinor, lcid, pptlib) = DLL("OLEAUT32.dll", "int LoadRegTypeLib(void*, int, int, dword, void*)")
# 呼び出し: LoadRegTypeLib(rguid, wVerMajor, wVerMinor, lcid, pptlib)
# rguid : GUID* -> "void*"
# wVerMajor : WORD -> "int"
# wVerMinor : WORD -> "int"
# lcid : DWORD -> "dword"
# pptlib : ITypeLib** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。