ホーム › NetworkManagement.P2P › DrtUpdateKey
DrtUpdateKey
関数DRTに登録済みキーのアプリデータを更新する。
シグネチャ
// drt.dll
#include <windows.h>
HRESULT DrtUpdateKey(
void* hKeyRegistration,
DRT_DATA* pAppData
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hKeyRegistration | void* | in | 更新対象のキー登録ハンドル。 |
| pAppData | DRT_DATA* | in | 新しいアプリケーションデータを格納したDRT_DATA構造体へのポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// drt.dll
#include <windows.h>
HRESULT DrtUpdateKey(
void* hKeyRegistration,
DRT_DATA* pAppData
);[DllImport("drt.dll", ExactSpelling = true)]
static extern int DrtUpdateKey(
IntPtr hKeyRegistration, // void*
IntPtr pAppData // DRT_DATA*
);<DllImport("drt.dll", ExactSpelling:=True)>
Public Shared Function DrtUpdateKey(
hKeyRegistration As IntPtr, ' void*
pAppData As IntPtr ' DRT_DATA*
) As Integer
End Function' hKeyRegistration : void*
' pAppData : DRT_DATA*
Declare PtrSafe Function DrtUpdateKey Lib "drt" ( _
ByVal hKeyRegistration As LongPtr, _
ByVal pAppData As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrtUpdateKey = ctypes.windll.drt.DrtUpdateKey
DrtUpdateKey.restype = ctypes.c_int
DrtUpdateKey.argtypes = [
ctypes.POINTER(None), # hKeyRegistration : void*
ctypes.c_void_p, # pAppData : DRT_DATA*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('drt.dll')
DrtUpdateKey = Fiddle::Function.new(
lib['DrtUpdateKey'],
[
Fiddle::TYPE_VOIDP, # hKeyRegistration : void*
Fiddle::TYPE_VOIDP, # pAppData : DRT_DATA*
],
Fiddle::TYPE_INT)#[link(name = "drt")]
extern "system" {
fn DrtUpdateKey(
hKeyRegistration: *mut (), // void*
pAppData: *mut DRT_DATA // DRT_DATA*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("drt.dll")]
public static extern int DrtUpdateKey(IntPtr hKeyRegistration, IntPtr pAppData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'drt_DrtUpdateKey' -Namespace Win32 -PassThru
# $api::DrtUpdateKey(hKeyRegistration, pAppData)#uselib "drt.dll"
#func global DrtUpdateKey "DrtUpdateKey" sptr, sptr
; DrtUpdateKey hKeyRegistration, varptr(pAppData) ; 戻り値は stat
; hKeyRegistration : void* -> "sptr"
; pAppData : DRT_DATA* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "drt.dll" #cfunc global DrtUpdateKey "DrtUpdateKey" sptr, var ; res = DrtUpdateKey(hKeyRegistration, pAppData) ; hKeyRegistration : void* -> "sptr" ; pAppData : DRT_DATA* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "drt.dll" #cfunc global DrtUpdateKey "DrtUpdateKey" sptr, sptr ; res = DrtUpdateKey(hKeyRegistration, varptr(pAppData)) ; hKeyRegistration : void* -> "sptr" ; pAppData : DRT_DATA* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DrtUpdateKey(void* hKeyRegistration, DRT_DATA* pAppData) #uselib "drt.dll" #cfunc global DrtUpdateKey "DrtUpdateKey" intptr, var ; res = DrtUpdateKey(hKeyRegistration, pAppData) ; hKeyRegistration : void* -> "intptr" ; pAppData : DRT_DATA* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DrtUpdateKey(void* hKeyRegistration, DRT_DATA* pAppData) #uselib "drt.dll" #cfunc global DrtUpdateKey "DrtUpdateKey" intptr, intptr ; res = DrtUpdateKey(hKeyRegistration, varptr(pAppData)) ; hKeyRegistration : void* -> "intptr" ; pAppData : DRT_DATA* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
drt = windows.NewLazySystemDLL("drt.dll")
procDrtUpdateKey = drt.NewProc("DrtUpdateKey")
)
// hKeyRegistration (void*), pAppData (DRT_DATA*)
r1, _, err := procDrtUpdateKey.Call(
uintptr(hKeyRegistration),
uintptr(pAppData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DrtUpdateKey(
hKeyRegistration: Pointer; // void*
pAppData: Pointer // DRT_DATA*
): Integer; stdcall;
external 'drt.dll' name 'DrtUpdateKey';result := DllCall("drt\DrtUpdateKey"
, "Ptr", hKeyRegistration ; void*
, "Ptr", pAppData ; DRT_DATA*
, "Int") ; return: HRESULT●DrtUpdateKey(hKeyRegistration, pAppData) = DLL("drt.dll", "int DrtUpdateKey(void*, void*)")
# 呼び出し: DrtUpdateKey(hKeyRegistration, pAppData)
# hKeyRegistration : void* -> "void*"
# pAppData : DRT_DATA* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "drt" fn DrtUpdateKey(
hKeyRegistration: ?*anyopaque, // void*
pAppData: [*c]DRT_DATA // DRT_DATA*
) callconv(std.os.windows.WINAPI) i32;proc DrtUpdateKey(
hKeyRegistration: pointer, # void*
pAppData: ptr DRT_DATA # DRT_DATA*
): int32 {.importc: "DrtUpdateKey", stdcall, dynlib: "drt.dll".}pragma(lib, "drt");
extern(Windows)
int DrtUpdateKey(
void* hKeyRegistration, // void*
DRT_DATA* pAppData // DRT_DATA*
);ccall((:DrtUpdateKey, "drt.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{DRT_DATA}),
hKeyRegistration, pAppData)
# hKeyRegistration : void* -> Ptr{Cvoid}
# pAppData : DRT_DATA* -> Ptr{DRT_DATA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DrtUpdateKey(
void* hKeyRegistration,
void* pAppData);
]]
local drt = ffi.load("drt")
-- drt.DrtUpdateKey(hKeyRegistration, pAppData)
-- hKeyRegistration : void*
-- pAppData : DRT_DATA*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('drt.dll');
const DrtUpdateKey = lib.func('__stdcall', 'DrtUpdateKey', 'int32_t', ['void *', 'void *']);
// DrtUpdateKey(hKeyRegistration, pAppData)
// hKeyRegistration : void* -> 'void *'
// pAppData : DRT_DATA* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("drt.dll", {
DrtUpdateKey: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.DrtUpdateKey(hKeyRegistration, pAppData)
// hKeyRegistration : void* -> "pointer"
// pAppData : DRT_DATA* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DrtUpdateKey(
void* hKeyRegistration,
void* pAppData);
C, "drt.dll");
// $ffi->DrtUpdateKey(hKeyRegistration, pAppData);
// hKeyRegistration : void*
// pAppData : DRT_DATA*
// 構造体/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 Drt extends StdCallLibrary {
Drt INSTANCE = Native.load("drt", Drt.class);
int DrtUpdateKey(
Pointer hKeyRegistration, // void*
Pointer pAppData // DRT_DATA*
);
}@[Link("drt")]
lib Libdrt
fun DrtUpdateKey = DrtUpdateKey(
hKeyRegistration : Void*, # void*
pAppData : DRT_DATA* # DRT_DATA*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DrtUpdateKeyNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef DrtUpdateKeyDart = int Function(Pointer<Void>, Pointer<Void>);
final DrtUpdateKey = DynamicLibrary.open('drt.dll')
.lookupFunction<DrtUpdateKeyNative, DrtUpdateKeyDart>('DrtUpdateKey');
// hKeyRegistration : void* -> Pointer<Void>
// pAppData : DRT_DATA* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DrtUpdateKey(
hKeyRegistration: Pointer; // void*
pAppData: Pointer // DRT_DATA*
): Integer; stdcall;
external 'drt.dll' name 'DrtUpdateKey';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DrtUpdateKey"
c_DrtUpdateKey :: Ptr () -> Ptr () -> IO Int32
-- hKeyRegistration : void* -> Ptr ()
-- pAppData : DRT_DATA* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drtupdatekey =
foreign "DrtUpdateKey"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hKeyRegistration : void* -> (ptr void) *)
(* pAppData : DRT_DATA* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library drt (t "drt.dll"))
(cffi:use-foreign-library drt)
(cffi:defcfun ("DrtUpdateKey" drt-update-key :convention :stdcall) :int32
(h-key-registration :pointer) ; void*
(p-app-data :pointer)) ; DRT_DATA*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DrtUpdateKey = Win32::API::More->new('drt',
'int DrtUpdateKey(LPVOID hKeyRegistration, LPVOID pAppData)');
# my $ret = $DrtUpdateKey->Call($hKeyRegistration, $pAppData);
# hKeyRegistration : void* -> LPVOID
# pAppData : DRT_DATA* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型