ホーム › System.Ole › OleRegGetUserType
OleRegGetUserType
関数レジストリからCLSIDのユーザー表示用タイプ名を取得する。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT OleRegGetUserType(
const GUID* clsid,
DWORD dwFormOfType,
LPWSTR* pszUserType
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| clsid | GUID* | in |
| dwFormOfType | DWORD | in |
| pszUserType | LPWSTR* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT OleRegGetUserType(
const GUID* clsid,
DWORD dwFormOfType,
LPWSTR* pszUserType
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int OleRegGetUserType(
ref Guid clsid, // GUID*
uint dwFormOfType, // DWORD
IntPtr pszUserType // LPWSTR* out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function OleRegGetUserType(
ByRef clsid As Guid, ' GUID*
dwFormOfType As UInteger, ' DWORD
pszUserType As IntPtr ' LPWSTR* out
) As Integer
End Function' clsid : GUID*
' dwFormOfType : DWORD
' pszUserType : LPWSTR* out
Declare PtrSafe Function OleRegGetUserType Lib "ole32" ( _
ByVal clsid As LongPtr, _
ByVal dwFormOfType As Long, _
ByVal pszUserType As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
OleRegGetUserType = ctypes.windll.ole32.OleRegGetUserType
OleRegGetUserType.restype = ctypes.c_int
OleRegGetUserType.argtypes = [
ctypes.c_void_p, # clsid : GUID*
wintypes.DWORD, # dwFormOfType : DWORD
ctypes.c_void_p, # pszUserType : LPWSTR* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
OleRegGetUserType = Fiddle::Function.new(
lib['OleRegGetUserType'],
[
Fiddle::TYPE_VOIDP, # clsid : GUID*
-Fiddle::TYPE_INT, # dwFormOfType : DWORD
Fiddle::TYPE_VOIDP, # pszUserType : LPWSTR* out
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn OleRegGetUserType(
clsid: *const GUID, // GUID*
dwFormOfType: u32, // DWORD
pszUserType: *mut *mut u16 // LPWSTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int OleRegGetUserType(ref Guid clsid, uint dwFormOfType, IntPtr pszUserType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_OleRegGetUserType' -Namespace Win32 -PassThru
# $api::OleRegGetUserType(clsid, dwFormOfType, pszUserType)#uselib "OLE32.dll"
#func global OleRegGetUserType "OleRegGetUserType" sptr, sptr, sptr
; OleRegGetUserType varptr(clsid), dwFormOfType, varptr(pszUserType) ; 戻り値は stat
; clsid : GUID* -> "sptr"
; dwFormOfType : DWORD -> "sptr"
; pszUserType : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "OLE32.dll" #cfunc global OleRegGetUserType "OleRegGetUserType" var, int, var ; res = OleRegGetUserType(clsid, dwFormOfType, pszUserType) ; clsid : GUID* -> "var" ; dwFormOfType : DWORD -> "int" ; pszUserType : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "OLE32.dll" #cfunc global OleRegGetUserType "OleRegGetUserType" sptr, int, sptr ; res = OleRegGetUserType(varptr(clsid), dwFormOfType, varptr(pszUserType)) ; clsid : GUID* -> "sptr" ; dwFormOfType : DWORD -> "int" ; pszUserType : LPWSTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT OleRegGetUserType(GUID* clsid, DWORD dwFormOfType, LPWSTR* pszUserType) #uselib "OLE32.dll" #cfunc global OleRegGetUserType "OleRegGetUserType" var, int, var ; res = OleRegGetUserType(clsid, dwFormOfType, pszUserType) ; clsid : GUID* -> "var" ; dwFormOfType : DWORD -> "int" ; pszUserType : LPWSTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT OleRegGetUserType(GUID* clsid, DWORD dwFormOfType, LPWSTR* pszUserType) #uselib "OLE32.dll" #cfunc global OleRegGetUserType "OleRegGetUserType" intptr, int, intptr ; res = OleRegGetUserType(varptr(clsid), dwFormOfType, varptr(pszUserType)) ; clsid : GUID* -> "intptr" ; dwFormOfType : DWORD -> "int" ; pszUserType : LPWSTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procOleRegGetUserType = ole32.NewProc("OleRegGetUserType")
)
// clsid (GUID*), dwFormOfType (DWORD), pszUserType (LPWSTR* out)
r1, _, err := procOleRegGetUserType.Call(
uintptr(clsid),
uintptr(dwFormOfType),
uintptr(pszUserType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction OleRegGetUserType(
clsid: PGUID; // GUID*
dwFormOfType: DWORD; // DWORD
pszUserType: PPWideChar // LPWSTR* out
): Integer; stdcall;
external 'OLE32.dll' name 'OleRegGetUserType';result := DllCall("OLE32\OleRegGetUserType"
, "Ptr", clsid ; GUID*
, "UInt", dwFormOfType ; DWORD
, "Ptr", pszUserType ; LPWSTR* out
, "Int") ; return: HRESULT●OleRegGetUserType(clsid, dwFormOfType, pszUserType) = DLL("OLE32.dll", "int OleRegGetUserType(void*, dword, void*)")
# 呼び出し: OleRegGetUserType(clsid, dwFormOfType, pszUserType)
# clsid : GUID* -> "void*"
# dwFormOfType : DWORD -> "dword"
# pszUserType : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。