ホーム › System.Ole › RegisterTypeLib
RegisterTypeLib
関数タイプライブラリの情報をシステムレジストリに登録する。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
HRESULT RegisterTypeLib(
ITypeLib* ptlib,
LPCWSTR szFullPath,
LPCWSTR szHelpDir // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ptlib | ITypeLib* | in | タイプライブラリ。 |
| szFullPath | LPCWSTR | in | タイプライブラリの完全修飾パス指定。 |
| szHelpDir | LPCWSTR | inoptional | 登録するライブラリのヘルプファイルが格納されているディレクトリ。このパラメーターには null を指定できます。 |
戻り値の型: HRESULT
公式ドキュメント
タイプライブラリに関する情報をシステムレジストリに追加します。
戻り値
この関数は次のいずれかの値を返すことがあります。
| 戻り値 | 説明 |
|---|---|
| 成功しました。 | |
| 1 つ以上の引数が無効です。 | |
| 操作を完了するためのメモリが不足しています。 | |
| 関数がファイルに書き込めませんでした。 | |
| システム登録データベースを開けませんでした。 | |
| タイプライブラリを開けませんでした。 |
解説(Remarks)
この関数は、アプリケーションの初期化時に、そのアプリケーションのタイプライブラリを正しく登録するために使用できます。RegisterTypeLib を呼び出してタイプライブラリを登録すると、マイナーバージョン番号とメジャーバージョン番号の両方が 16 進数で登録されます。
タイプライブラリキーの下に完全なレジストリエントリを書き込むことに加えて、RegisterTypeLib は各 dispinterface および Automation 互換インターフェイス(デュアルインターフェイスを含む)のエントリを追加します。この情報は、これらのインターフェイスのインスタンスを作成するために必要です。コクラスは登録されません(つまり、RegisterTypeLib はコクラスの CLSID キーに値を書き込みません)。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
HRESULT RegisterTypeLib(
ITypeLib* ptlib,
LPCWSTR szFullPath,
LPCWSTR szHelpDir // optional
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int RegisterTypeLib(
IntPtr ptlib, // ITypeLib*
[MarshalAs(UnmanagedType.LPWStr)] string szFullPath, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szHelpDir // LPCWSTR optional
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function RegisterTypeLib(
ptlib As IntPtr, ' ITypeLib*
<MarshalAs(UnmanagedType.LPWStr)> szFullPath As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> szHelpDir As String ' LPCWSTR optional
) As Integer
End Function' ptlib : ITypeLib*
' szFullPath : LPCWSTR
' szHelpDir : LPCWSTR optional
Declare PtrSafe Function RegisterTypeLib Lib "oleaut32" ( _
ByVal ptlib As LongPtr, _
ByVal szFullPath As LongPtr, _
ByVal szHelpDir As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterTypeLib = ctypes.windll.oleaut32.RegisterTypeLib
RegisterTypeLib.restype = ctypes.c_int
RegisterTypeLib.argtypes = [
ctypes.c_void_p, # ptlib : ITypeLib*
wintypes.LPCWSTR, # szFullPath : LPCWSTR
wintypes.LPCWSTR, # szHelpDir : LPCWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
RegisterTypeLib = Fiddle::Function.new(
lib['RegisterTypeLib'],
[
Fiddle::TYPE_VOIDP, # ptlib : ITypeLib*
Fiddle::TYPE_VOIDP, # szFullPath : LPCWSTR
Fiddle::TYPE_VOIDP, # szHelpDir : LPCWSTR optional
],
Fiddle::TYPE_INT)#[link(name = "oleaut32")]
extern "system" {
fn RegisterTypeLib(
ptlib: *mut core::ffi::c_void, // ITypeLib*
szFullPath: *const u16, // LPCWSTR
szHelpDir: *const u16 // LPCWSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int RegisterTypeLib(IntPtr ptlib, [MarshalAs(UnmanagedType.LPWStr)] string szFullPath, [MarshalAs(UnmanagedType.LPWStr)] string szHelpDir);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_RegisterTypeLib' -Namespace Win32 -PassThru
# $api::RegisterTypeLib(ptlib, szFullPath, szHelpDir)#uselib "OLEAUT32.dll"
#func global RegisterTypeLib "RegisterTypeLib" sptr, sptr, sptr
; RegisterTypeLib ptlib, szFullPath, szHelpDir ; 戻り値は stat
; ptlib : ITypeLib* -> "sptr"
; szFullPath : LPCWSTR -> "sptr"
; szHelpDir : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLEAUT32.dll"
#cfunc global RegisterTypeLib "RegisterTypeLib" sptr, wstr, wstr
; res = RegisterTypeLib(ptlib, szFullPath, szHelpDir)
; ptlib : ITypeLib* -> "sptr"
; szFullPath : LPCWSTR -> "wstr"
; szHelpDir : LPCWSTR optional -> "wstr"; HRESULT RegisterTypeLib(ITypeLib* ptlib, LPCWSTR szFullPath, LPCWSTR szHelpDir)
#uselib "OLEAUT32.dll"
#cfunc global RegisterTypeLib "RegisterTypeLib" intptr, wstr, wstr
; res = RegisterTypeLib(ptlib, szFullPath, szHelpDir)
; ptlib : ITypeLib* -> "intptr"
; szFullPath : LPCWSTR -> "wstr"
; szHelpDir : LPCWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procRegisterTypeLib = oleaut32.NewProc("RegisterTypeLib")
)
// ptlib (ITypeLib*), szFullPath (LPCWSTR), szHelpDir (LPCWSTR optional)
r1, _, err := procRegisterTypeLib.Call(
uintptr(ptlib),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szFullPath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szHelpDir))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RegisterTypeLib(
ptlib: Pointer; // ITypeLib*
szFullPath: PWideChar; // LPCWSTR
szHelpDir: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'OLEAUT32.dll' name 'RegisterTypeLib';result := DllCall("OLEAUT32\RegisterTypeLib"
, "Ptr", ptlib ; ITypeLib*
, "WStr", szFullPath ; LPCWSTR
, "WStr", szHelpDir ; LPCWSTR optional
, "Int") ; return: HRESULT●RegisterTypeLib(ptlib, szFullPath, szHelpDir) = DLL("OLEAUT32.dll", "int RegisterTypeLib(void*, char*, char*)")
# 呼び出し: RegisterTypeLib(ptlib, szFullPath, szHelpDir)
# ptlib : ITypeLib* -> "void*"
# szFullPath : LPCWSTR -> "char*"
# szHelpDir : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "oleaut32" fn RegisterTypeLib(
ptlib: ?*anyopaque, // ITypeLib*
szFullPath: [*c]const u16, // LPCWSTR
szHelpDir: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;proc RegisterTypeLib(
ptlib: pointer, # ITypeLib*
szFullPath: WideCString, # LPCWSTR
szHelpDir: WideCString # LPCWSTR optional
): int32 {.importc: "RegisterTypeLib", stdcall, dynlib: "OLEAUT32.dll".}pragma(lib, "oleaut32");
extern(Windows)
int RegisterTypeLib(
void* ptlib, // ITypeLib*
const(wchar)* szFullPath, // LPCWSTR
const(wchar)* szHelpDir // LPCWSTR optional
);ccall((:RegisterTypeLib, "OLEAUT32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Cwstring, Cwstring),
ptlib, szFullPath, szHelpDir)
# ptlib : ITypeLib* -> Ptr{Cvoid}
# szFullPath : LPCWSTR -> Cwstring
# szHelpDir : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RegisterTypeLib(
void* ptlib,
const uint16_t* szFullPath,
const uint16_t* szHelpDir);
]]
local oleaut32 = ffi.load("oleaut32")
-- oleaut32.RegisterTypeLib(ptlib, szFullPath, szHelpDir)
-- ptlib : ITypeLib*
-- szFullPath : LPCWSTR
-- szHelpDir : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('OLEAUT32.dll');
const RegisterTypeLib = lib.func('__stdcall', 'RegisterTypeLib', 'int32_t', ['void *', 'str16', 'str16']);
// RegisterTypeLib(ptlib, szFullPath, szHelpDir)
// ptlib : ITypeLib* -> 'void *'
// szFullPath : LPCWSTR -> 'str16'
// szHelpDir : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("OLEAUT32.dll", {
RegisterTypeLib: { parameters: ["pointer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.RegisterTypeLib(ptlib, szFullPath, szHelpDir)
// ptlib : ITypeLib* -> "pointer"
// szFullPath : LPCWSTR -> "buffer"
// szHelpDir : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RegisterTypeLib(
void* ptlib,
const uint16_t* szFullPath,
const uint16_t* szHelpDir);
C, "OLEAUT32.dll");
// $ffi->RegisterTypeLib(ptlib, szFullPath, szHelpDir);
// ptlib : ITypeLib*
// szFullPath : LPCWSTR
// szHelpDir : LPCWSTR optional
// 構造体/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 Oleaut32 extends StdCallLibrary {
Oleaut32 INSTANCE = Native.load("oleaut32", Oleaut32.class);
int RegisterTypeLib(
Pointer ptlib, // ITypeLib*
WString szFullPath, // LPCWSTR
WString szHelpDir // LPCWSTR optional
);
}@[Link("oleaut32")]
lib LibOLEAUT32
fun RegisterTypeLib = RegisterTypeLib(
ptlib : Void*, # ITypeLib*
szFullPath : UInt16*, # LPCWSTR
szHelpDir : UInt16* # LPCWSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RegisterTypeLibNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>);
typedef RegisterTypeLibDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>);
final RegisterTypeLib = DynamicLibrary.open('OLEAUT32.dll')
.lookupFunction<RegisterTypeLibNative, RegisterTypeLibDart>('RegisterTypeLib');
// ptlib : ITypeLib* -> Pointer<Void>
// szFullPath : LPCWSTR -> Pointer<Utf16>
// szHelpDir : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RegisterTypeLib(
ptlib: Pointer; // ITypeLib*
szFullPath: PWideChar; // LPCWSTR
szHelpDir: PWideChar // LPCWSTR optional
): Integer; stdcall;
external 'OLEAUT32.dll' name 'RegisterTypeLib';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegisterTypeLib"
c_RegisterTypeLib :: Ptr () -> CWString -> CWString -> IO Int32
-- ptlib : ITypeLib* -> Ptr ()
-- szFullPath : LPCWSTR -> CWString
-- szHelpDir : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let registertypelib =
foreign "RegisterTypeLib"
((ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* ptlib : ITypeLib* -> (ptr void) *)
(* szFullPath : LPCWSTR -> (ptr uint16_t) *)
(* szHelpDir : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library oleaut32 (t "OLEAUT32.dll"))
(cffi:use-foreign-library oleaut32)
(cffi:defcfun ("RegisterTypeLib" register-type-lib :convention :stdcall) :int32
(ptlib :pointer) ; ITypeLib*
(sz-full-path (:string :encoding :utf-16le)) ; LPCWSTR
(sz-help-dir (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegisterTypeLib = Win32::API::More->new('OLEAUT32',
'int RegisterTypeLib(LPVOID ptlib, LPCWSTR szFullPath, LPCWSTR szHelpDir)');
# my $ret = $RegisterTypeLib->Call($ptlib, $szFullPath, $szHelpDir);
# ptlib : ITypeLib* -> LPVOID
# szFullPath : LPCWSTR -> LPCWSTR
# szHelpDir : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型