ホーム › NetworkManagement.P2P › DrtRegisterKey
DrtRegisterKey
関数DRTにキーを登録して公開する。
シグネチャ
// drt.dll
#include <windows.h>
HRESULT DrtRegisterKey(
void* hDrt,
DRT_REGISTRATION* pRegistration,
void* pvKeyContext, // optional
void** phKeyRegistration
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hDrt | void* | in |
| pRegistration | DRT_REGISTRATION* | in |
| pvKeyContext | void* | inoptional |
| phKeyRegistration | void** | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// drt.dll
#include <windows.h>
HRESULT DrtRegisterKey(
void* hDrt,
DRT_REGISTRATION* pRegistration,
void* pvKeyContext, // optional
void** phKeyRegistration
);[DllImport("drt.dll", ExactSpelling = true)]
static extern int DrtRegisterKey(
IntPtr hDrt, // void*
IntPtr pRegistration, // DRT_REGISTRATION*
IntPtr pvKeyContext, // void* optional
IntPtr phKeyRegistration // void** out
);<DllImport("drt.dll", ExactSpelling:=True)>
Public Shared Function DrtRegisterKey(
hDrt As IntPtr, ' void*
pRegistration As IntPtr, ' DRT_REGISTRATION*
pvKeyContext As IntPtr, ' void* optional
phKeyRegistration As IntPtr ' void** out
) As Integer
End Function' hDrt : void*
' pRegistration : DRT_REGISTRATION*
' pvKeyContext : void* optional
' phKeyRegistration : void** out
Declare PtrSafe Function DrtRegisterKey Lib "drt" ( _
ByVal hDrt As LongPtr, _
ByVal pRegistration As LongPtr, _
ByVal pvKeyContext As LongPtr, _
ByVal phKeyRegistration As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrtRegisterKey = ctypes.windll.drt.DrtRegisterKey
DrtRegisterKey.restype = ctypes.c_int
DrtRegisterKey.argtypes = [
ctypes.POINTER(None), # hDrt : void*
ctypes.c_void_p, # pRegistration : DRT_REGISTRATION*
ctypes.POINTER(None), # pvKeyContext : void* optional
ctypes.c_void_p, # phKeyRegistration : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('drt.dll')
DrtRegisterKey = Fiddle::Function.new(
lib['DrtRegisterKey'],
[
Fiddle::TYPE_VOIDP, # hDrt : void*
Fiddle::TYPE_VOIDP, # pRegistration : DRT_REGISTRATION*
Fiddle::TYPE_VOIDP, # pvKeyContext : void* optional
Fiddle::TYPE_VOIDP, # phKeyRegistration : void** out
],
Fiddle::TYPE_INT)#[link(name = "drt")]
extern "system" {
fn DrtRegisterKey(
hDrt: *mut (), // void*
pRegistration: *mut DRT_REGISTRATION, // DRT_REGISTRATION*
pvKeyContext: *mut (), // void* optional
phKeyRegistration: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("drt.dll")]
public static extern int DrtRegisterKey(IntPtr hDrt, IntPtr pRegistration, IntPtr pvKeyContext, IntPtr phKeyRegistration);
"@
$api = Add-Type -MemberDefinition $sig -Name 'drt_DrtRegisterKey' -Namespace Win32 -PassThru
# $api::DrtRegisterKey(hDrt, pRegistration, pvKeyContext, phKeyRegistration)#uselib "drt.dll"
#func global DrtRegisterKey "DrtRegisterKey" sptr, sptr, sptr, sptr
; DrtRegisterKey hDrt, varptr(pRegistration), pvKeyContext, phKeyRegistration ; 戻り値は stat
; hDrt : void* -> "sptr"
; pRegistration : DRT_REGISTRATION* -> "sptr"
; pvKeyContext : void* optional -> "sptr"
; phKeyRegistration : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "drt.dll" #cfunc global DrtRegisterKey "DrtRegisterKey" sptr, var, sptr, sptr ; res = DrtRegisterKey(hDrt, pRegistration, pvKeyContext, phKeyRegistration) ; hDrt : void* -> "sptr" ; pRegistration : DRT_REGISTRATION* -> "var" ; pvKeyContext : void* optional -> "sptr" ; phKeyRegistration : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "drt.dll" #cfunc global DrtRegisterKey "DrtRegisterKey" sptr, sptr, sptr, sptr ; res = DrtRegisterKey(hDrt, varptr(pRegistration), pvKeyContext, phKeyRegistration) ; hDrt : void* -> "sptr" ; pRegistration : DRT_REGISTRATION* -> "sptr" ; pvKeyContext : void* optional -> "sptr" ; phKeyRegistration : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DrtRegisterKey(void* hDrt, DRT_REGISTRATION* pRegistration, void* pvKeyContext, void** phKeyRegistration) #uselib "drt.dll" #cfunc global DrtRegisterKey "DrtRegisterKey" intptr, var, intptr, intptr ; res = DrtRegisterKey(hDrt, pRegistration, pvKeyContext, phKeyRegistration) ; hDrt : void* -> "intptr" ; pRegistration : DRT_REGISTRATION* -> "var" ; pvKeyContext : void* optional -> "intptr" ; phKeyRegistration : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DrtRegisterKey(void* hDrt, DRT_REGISTRATION* pRegistration, void* pvKeyContext, void** phKeyRegistration) #uselib "drt.dll" #cfunc global DrtRegisterKey "DrtRegisterKey" intptr, intptr, intptr, intptr ; res = DrtRegisterKey(hDrt, varptr(pRegistration), pvKeyContext, phKeyRegistration) ; hDrt : void* -> "intptr" ; pRegistration : DRT_REGISTRATION* -> "intptr" ; pvKeyContext : void* optional -> "intptr" ; phKeyRegistration : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
drt = windows.NewLazySystemDLL("drt.dll")
procDrtRegisterKey = drt.NewProc("DrtRegisterKey")
)
// hDrt (void*), pRegistration (DRT_REGISTRATION*), pvKeyContext (void* optional), phKeyRegistration (void** out)
r1, _, err := procDrtRegisterKey.Call(
uintptr(hDrt),
uintptr(pRegistration),
uintptr(pvKeyContext),
uintptr(phKeyRegistration),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DrtRegisterKey(
hDrt: Pointer; // void*
pRegistration: Pointer; // DRT_REGISTRATION*
pvKeyContext: Pointer; // void* optional
phKeyRegistration: Pointer // void** out
): Integer; stdcall;
external 'drt.dll' name 'DrtRegisterKey';result := DllCall("drt\DrtRegisterKey"
, "Ptr", hDrt ; void*
, "Ptr", pRegistration ; DRT_REGISTRATION*
, "Ptr", pvKeyContext ; void* optional
, "Ptr", phKeyRegistration ; void** out
, "Int") ; return: HRESULT●DrtRegisterKey(hDrt, pRegistration, pvKeyContext, phKeyRegistration) = DLL("drt.dll", "int DrtRegisterKey(void*, void*, void*, void*)")
# 呼び出し: DrtRegisterKey(hDrt, pRegistration, pvKeyContext, phKeyRegistration)
# hDrt : void* -> "void*"
# pRegistration : DRT_REGISTRATION* -> "void*"
# pvKeyContext : void* optional -> "void*"
# phKeyRegistration : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。