ホーム › System.Ole › RegisterTypeLibForUser
RegisterTypeLibForUser
関数タイプライブラリを現在のユーザー単位でレジストリに登録する。
シグネチャ
// OLEAUT32.dll
#include <windows.h>
HRESULT RegisterTypeLibForUser(
ITypeLib* ptlib,
LPWSTR szFullPath,
LPWSTR szHelpDir // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ptlib | ITypeLib* | in |
| szFullPath | LPWSTR | in |
| szHelpDir | LPWSTR | inoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLEAUT32.dll
#include <windows.h>
HRESULT RegisterTypeLibForUser(
ITypeLib* ptlib,
LPWSTR szFullPath,
LPWSTR szHelpDir // optional
);[DllImport("OLEAUT32.dll", ExactSpelling = true)]
static extern int RegisterTypeLibForUser(
IntPtr ptlib, // ITypeLib*
[MarshalAs(UnmanagedType.LPWStr)] string szFullPath, // LPWSTR
[MarshalAs(UnmanagedType.LPWStr)] string szHelpDir // LPWSTR optional
);<DllImport("OLEAUT32.dll", ExactSpelling:=True)>
Public Shared Function RegisterTypeLibForUser(
ptlib As IntPtr, ' ITypeLib*
<MarshalAs(UnmanagedType.LPWStr)> szFullPath As String, ' LPWSTR
<MarshalAs(UnmanagedType.LPWStr)> szHelpDir As String ' LPWSTR optional
) As Integer
End Function' ptlib : ITypeLib*
' szFullPath : LPWSTR
' szHelpDir : LPWSTR optional
Declare PtrSafe Function RegisterTypeLibForUser 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
RegisterTypeLibForUser = ctypes.windll.oleaut32.RegisterTypeLibForUser
RegisterTypeLibForUser.restype = ctypes.c_int
RegisterTypeLibForUser.argtypes = [
ctypes.c_void_p, # ptlib : ITypeLib*
wintypes.LPCWSTR, # szFullPath : LPWSTR
wintypes.LPCWSTR, # szHelpDir : LPWSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLEAUT32.dll')
RegisterTypeLibForUser = Fiddle::Function.new(
lib['RegisterTypeLibForUser'],
[
Fiddle::TYPE_VOIDP, # ptlib : ITypeLib*
Fiddle::TYPE_VOIDP, # szFullPath : LPWSTR
Fiddle::TYPE_VOIDP, # szHelpDir : LPWSTR optional
],
Fiddle::TYPE_INT)#[link(name = "oleaut32")]
extern "system" {
fn RegisterTypeLibForUser(
ptlib: *mut core::ffi::c_void, // ITypeLib*
szFullPath: *mut u16, // LPWSTR
szHelpDir: *mut u16 // LPWSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLEAUT32.dll")]
public static extern int RegisterTypeLibForUser(IntPtr ptlib, [MarshalAs(UnmanagedType.LPWStr)] string szFullPath, [MarshalAs(UnmanagedType.LPWStr)] string szHelpDir);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLEAUT32_RegisterTypeLibForUser' -Namespace Win32 -PassThru
# $api::RegisterTypeLibForUser(ptlib, szFullPath, szHelpDir)#uselib "OLEAUT32.dll"
#func global RegisterTypeLibForUser "RegisterTypeLibForUser" sptr, sptr, sptr
; RegisterTypeLibForUser ptlib, szFullPath, szHelpDir ; 戻り値は stat
; ptlib : ITypeLib* -> "sptr"
; szFullPath : LPWSTR -> "sptr"
; szHelpDir : LPWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLEAUT32.dll"
#cfunc global RegisterTypeLibForUser "RegisterTypeLibForUser" sptr, wstr, wstr
; res = RegisterTypeLibForUser(ptlib, szFullPath, szHelpDir)
; ptlib : ITypeLib* -> "sptr"
; szFullPath : LPWSTR -> "wstr"
; szHelpDir : LPWSTR optional -> "wstr"; HRESULT RegisterTypeLibForUser(ITypeLib* ptlib, LPWSTR szFullPath, LPWSTR szHelpDir)
#uselib "OLEAUT32.dll"
#cfunc global RegisterTypeLibForUser "RegisterTypeLibForUser" intptr, wstr, wstr
; res = RegisterTypeLibForUser(ptlib, szFullPath, szHelpDir)
; ptlib : ITypeLib* -> "intptr"
; szFullPath : LPWSTR -> "wstr"
; szHelpDir : LPWSTR optional -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
oleaut32 = windows.NewLazySystemDLL("OLEAUT32.dll")
procRegisterTypeLibForUser = oleaut32.NewProc("RegisterTypeLibForUser")
)
// ptlib (ITypeLib*), szFullPath (LPWSTR), szHelpDir (LPWSTR optional)
r1, _, err := procRegisterTypeLibForUser.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 RegisterTypeLibForUser(
ptlib: Pointer; // ITypeLib*
szFullPath: PWideChar; // LPWSTR
szHelpDir: PWideChar // LPWSTR optional
): Integer; stdcall;
external 'OLEAUT32.dll' name 'RegisterTypeLibForUser';result := DllCall("OLEAUT32\RegisterTypeLibForUser"
, "Ptr", ptlib ; ITypeLib*
, "WStr", szFullPath ; LPWSTR
, "WStr", szHelpDir ; LPWSTR optional
, "Int") ; return: HRESULT●RegisterTypeLibForUser(ptlib, szFullPath, szHelpDir) = DLL("OLEAUT32.dll", "int RegisterTypeLibForUser(void*, char*, char*)")
# 呼び出し: RegisterTypeLibForUser(ptlib, szFullPath, szHelpDir)
# ptlib : ITypeLib* -> "void*"
# szFullPath : LPWSTR -> "char*"
# szHelpDir : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。