ホーム › Networking.Clustering › GetClusterNetInterfaceKey
GetClusterNetInterfaceKey
関数ネットワークインターフェイスのレジストリキーを開いて取得する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
HKEY GetClusterNetInterfaceKey(
HNETINTERFACE hNetInterface,
DWORD samDesired
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hNetInterface | HNETINTERFACE | in | レジストリキーを取得する対象のネットワークインターフェイスハンドル。 |
| samDesired | DWORD | in | 開くレジストリキーに要求するアクセス権(KEY_READ等)。 |
戻り値の型: HKEY
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
HKEY GetClusterNetInterfaceKey(
HNETINTERFACE hNetInterface,
DWORD samDesired
);[DllImport("CLUSAPI.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr GetClusterNetInterfaceKey(
IntPtr hNetInterface, // HNETINTERFACE
uint samDesired // DWORD
);<DllImport("CLUSAPI.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetClusterNetInterfaceKey(
hNetInterface As IntPtr, ' HNETINTERFACE
samDesired As UInteger ' DWORD
) As IntPtr
End Function' hNetInterface : HNETINTERFACE
' samDesired : DWORD
Declare PtrSafe Function GetClusterNetInterfaceKey Lib "clusapi" ( _
ByVal hNetInterface As LongPtr, _
ByVal samDesired As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetClusterNetInterfaceKey = ctypes.windll.clusapi.GetClusterNetInterfaceKey
GetClusterNetInterfaceKey.restype = ctypes.c_void_p
GetClusterNetInterfaceKey.argtypes = [
ctypes.c_ssize_t, # hNetInterface : HNETINTERFACE
wintypes.DWORD, # samDesired : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
GetClusterNetInterfaceKey = Fiddle::Function.new(
lib['GetClusterNetInterfaceKey'],
[
Fiddle::TYPE_INTPTR_T, # hNetInterface : HNETINTERFACE
-Fiddle::TYPE_INT, # samDesired : DWORD
],
Fiddle::TYPE_VOIDP)#[link(name = "clusapi")]
extern "system" {
fn GetClusterNetInterfaceKey(
hNetInterface: isize, // HNETINTERFACE
samDesired: u32 // DWORD
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll", SetLastError = true)]
public static extern IntPtr GetClusterNetInterfaceKey(IntPtr hNetInterface, uint samDesired);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_GetClusterNetInterfaceKey' -Namespace Win32 -PassThru
# $api::GetClusterNetInterfaceKey(hNetInterface, samDesired)#uselib "CLUSAPI.dll"
#func global GetClusterNetInterfaceKey "GetClusterNetInterfaceKey" sptr, sptr
; GetClusterNetInterfaceKey hNetInterface, samDesired ; 戻り値は stat
; hNetInterface : HNETINTERFACE -> "sptr"
; samDesired : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CLUSAPI.dll"
#cfunc global GetClusterNetInterfaceKey "GetClusterNetInterfaceKey" sptr, int
; res = GetClusterNetInterfaceKey(hNetInterface, samDesired)
; hNetInterface : HNETINTERFACE -> "sptr"
; samDesired : DWORD -> "int"; HKEY GetClusterNetInterfaceKey(HNETINTERFACE hNetInterface, DWORD samDesired)
#uselib "CLUSAPI.dll"
#cfunc global GetClusterNetInterfaceKey "GetClusterNetInterfaceKey" intptr, int
; res = GetClusterNetInterfaceKey(hNetInterface, samDesired)
; hNetInterface : HNETINTERFACE -> "intptr"
; samDesired : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procGetClusterNetInterfaceKey = clusapi.NewProc("GetClusterNetInterfaceKey")
)
// hNetInterface (HNETINTERFACE), samDesired (DWORD)
r1, _, err := procGetClusterNetInterfaceKey.Call(
uintptr(hNetInterface),
uintptr(samDesired),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HKEYfunction GetClusterNetInterfaceKey(
hNetInterface: NativeInt; // HNETINTERFACE
samDesired: DWORD // DWORD
): THandle; stdcall;
external 'CLUSAPI.dll' name 'GetClusterNetInterfaceKey';result := DllCall("CLUSAPI\GetClusterNetInterfaceKey"
, "Ptr", hNetInterface ; HNETINTERFACE
, "UInt", samDesired ; DWORD
, "Ptr") ; return: HKEY●GetClusterNetInterfaceKey(hNetInterface, samDesired) = DLL("CLUSAPI.dll", "void* GetClusterNetInterfaceKey(int, dword)")
# 呼び出し: GetClusterNetInterfaceKey(hNetInterface, samDesired)
# hNetInterface : HNETINTERFACE -> "int"
# samDesired : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "clusapi" fn GetClusterNetInterfaceKey(
hNetInterface: isize, // HNETINTERFACE
samDesired: u32 // DWORD
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc GetClusterNetInterfaceKey(
hNetInterface: int, # HNETINTERFACE
samDesired: uint32 # DWORD
): pointer {.importc: "GetClusterNetInterfaceKey", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
void* GetClusterNetInterfaceKey(
ptrdiff_t hNetInterface, // HNETINTERFACE
uint samDesired // DWORD
);ccall((:GetClusterNetInterfaceKey, "CLUSAPI.dll"), stdcall, Ptr{Cvoid},
(Int, UInt32),
hNetInterface, samDesired)
# hNetInterface : HNETINTERFACE -> Int
# samDesired : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* GetClusterNetInterfaceKey(
intptr_t hNetInterface,
uint32_t samDesired);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.GetClusterNetInterfaceKey(hNetInterface, samDesired)
-- hNetInterface : HNETINTERFACE
-- samDesired : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const GetClusterNetInterfaceKey = lib.func('__stdcall', 'GetClusterNetInterfaceKey', 'void *', ['intptr_t', 'uint32_t']);
// GetClusterNetInterfaceKey(hNetInterface, samDesired)
// hNetInterface : HNETINTERFACE -> 'intptr_t'
// samDesired : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
GetClusterNetInterfaceKey: { parameters: ["isize", "u32"], result: "pointer" },
});
// lib.symbols.GetClusterNetInterfaceKey(hNetInterface, samDesired)
// hNetInterface : HNETINTERFACE -> "isize"
// samDesired : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* GetClusterNetInterfaceKey(
intptr_t hNetInterface,
uint32_t samDesired);
C, "CLUSAPI.dll");
// $ffi->GetClusterNetInterfaceKey(hNetInterface, samDesired);
// hNetInterface : HNETINTERFACE
// samDesired : DWORD
// 構造体/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 Clusapi extends StdCallLibrary {
Clusapi INSTANCE = Native.load("clusapi", Clusapi.class);
Pointer GetClusterNetInterfaceKey(
long hNetInterface, // HNETINTERFACE
int samDesired // DWORD
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun GetClusterNetInterfaceKey = GetClusterNetInterfaceKey(
hNetInterface : LibC::SSizeT, # HNETINTERFACE
samDesired : UInt32 # DWORD
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetClusterNetInterfaceKeyNative = Pointer<Void> Function(IntPtr, Uint32);
typedef GetClusterNetInterfaceKeyDart = Pointer<Void> Function(int, int);
final GetClusterNetInterfaceKey = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<GetClusterNetInterfaceKeyNative, GetClusterNetInterfaceKeyDart>('GetClusterNetInterfaceKey');
// hNetInterface : HNETINTERFACE -> IntPtr
// samDesired : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetClusterNetInterfaceKey(
hNetInterface: NativeInt; // HNETINTERFACE
samDesired: DWORD // DWORD
): THandle; stdcall;
external 'CLUSAPI.dll' name 'GetClusterNetInterfaceKey';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetClusterNetInterfaceKey"
c_GetClusterNetInterfaceKey :: CIntPtr -> Word32 -> IO (Ptr ())
-- hNetInterface : HNETINTERFACE -> CIntPtr
-- samDesired : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getclusternetinterfacekey =
foreign "GetClusterNetInterfaceKey"
(intptr_t @-> uint32_t @-> returning (ptr void))
(* hNetInterface : HNETINTERFACE -> intptr_t *)
(* samDesired : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("GetClusterNetInterfaceKey" get-cluster-net-interface-key :convention :stdcall) :pointer
(h-net-interface :int64) ; HNETINTERFACE
(sam-desired :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetClusterNetInterfaceKey = Win32::API::More->new('CLUSAPI',
'HANDLE GetClusterNetInterfaceKey(LPARAM hNetInterface, DWORD samDesired)');
# my $ret = $GetClusterNetInterfaceKey->Call($hNetInterface, $samDesired);
# hNetInterface : HNETINTERFACE -> LPARAM
# samDesired : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。