ホーム › Networking.Clustering › ClusterRegReadBatchAddCommand
ClusterRegReadBatchAddCommand
関数読み取りバッチに値取得コマンドを追加する。
シグネチャ
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegReadBatchAddCommand(
HREGREADBATCH hRegReadBatch,
LPCWSTR wzSubkeyName,
LPCWSTR wzValueName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hRegReadBatch | HREGREADBATCH | in | コマンドを追加する対象の読み取りバッチハンドル。 |
| wzSubkeyName | LPCWSTR | in | 読み取り対象のサブキー名を示すワイド文字列。 |
| wzValueName | LPCWSTR | in | 読み取り対象の値名を示すワイド文字列。 |
戻り値の型: INT
各言語での呼び出し定義
// CLUSAPI.dll
#include <windows.h>
INT ClusterRegReadBatchAddCommand(
HREGREADBATCH hRegReadBatch,
LPCWSTR wzSubkeyName,
LPCWSTR wzValueName
);[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegReadBatchAddCommand(
IntPtr hRegReadBatch, // HREGREADBATCH
[MarshalAs(UnmanagedType.LPWStr)] string wzSubkeyName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string wzValueName // LPCWSTR
);<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegReadBatchAddCommand(
hRegReadBatch As IntPtr, ' HREGREADBATCH
<MarshalAs(UnmanagedType.LPWStr)> wzSubkeyName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> wzValueName As String ' LPCWSTR
) As Integer
End Function' hRegReadBatch : HREGREADBATCH
' wzSubkeyName : LPCWSTR
' wzValueName : LPCWSTR
Declare PtrSafe Function ClusterRegReadBatchAddCommand Lib "clusapi" ( _
ByVal hRegReadBatch As LongPtr, _
ByVal wzSubkeyName As LongPtr, _
ByVal wzValueName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ClusterRegReadBatchAddCommand = ctypes.windll.clusapi.ClusterRegReadBatchAddCommand
ClusterRegReadBatchAddCommand.restype = ctypes.c_int
ClusterRegReadBatchAddCommand.argtypes = [
ctypes.c_ssize_t, # hRegReadBatch : HREGREADBATCH
wintypes.LPCWSTR, # wzSubkeyName : LPCWSTR
wintypes.LPCWSTR, # wzValueName : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegReadBatchAddCommand = Fiddle::Function.new(
lib['ClusterRegReadBatchAddCommand'],
[
Fiddle::TYPE_INTPTR_T, # hRegReadBatch : HREGREADBATCH
Fiddle::TYPE_VOIDP, # wzSubkeyName : LPCWSTR
Fiddle::TYPE_VOIDP, # wzValueName : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "clusapi")]
extern "system" {
fn ClusterRegReadBatchAddCommand(
hRegReadBatch: isize, // HREGREADBATCH
wzSubkeyName: *const u16, // LPCWSTR
wzValueName: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegReadBatchAddCommand(IntPtr hRegReadBatch, [MarshalAs(UnmanagedType.LPWStr)] string wzSubkeyName, [MarshalAs(UnmanagedType.LPWStr)] string wzValueName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegReadBatchAddCommand' -Namespace Win32 -PassThru
# $api::ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)#uselib "CLUSAPI.dll"
#func global ClusterRegReadBatchAddCommand "ClusterRegReadBatchAddCommand" sptr, sptr, sptr
; ClusterRegReadBatchAddCommand hRegReadBatch, wzSubkeyName, wzValueName ; 戻り値は stat
; hRegReadBatch : HREGREADBATCH -> "sptr"
; wzSubkeyName : LPCWSTR -> "sptr"
; wzValueName : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CLUSAPI.dll"
#cfunc global ClusterRegReadBatchAddCommand "ClusterRegReadBatchAddCommand" sptr, wstr, wstr
; res = ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)
; hRegReadBatch : HREGREADBATCH -> "sptr"
; wzSubkeyName : LPCWSTR -> "wstr"
; wzValueName : LPCWSTR -> "wstr"; INT ClusterRegReadBatchAddCommand(HREGREADBATCH hRegReadBatch, LPCWSTR wzSubkeyName, LPCWSTR wzValueName)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegReadBatchAddCommand "ClusterRegReadBatchAddCommand" intptr, wstr, wstr
; res = ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)
; hRegReadBatch : HREGREADBATCH -> "intptr"
; wzSubkeyName : LPCWSTR -> "wstr"
; wzValueName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
procClusterRegReadBatchAddCommand = clusapi.NewProc("ClusterRegReadBatchAddCommand")
)
// hRegReadBatch (HREGREADBATCH), wzSubkeyName (LPCWSTR), wzValueName (LPCWSTR)
r1, _, err := procClusterRegReadBatchAddCommand.Call(
uintptr(hRegReadBatch),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wzSubkeyName))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wzValueName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction ClusterRegReadBatchAddCommand(
hRegReadBatch: NativeInt; // HREGREADBATCH
wzSubkeyName: PWideChar; // LPCWSTR
wzValueName: PWideChar // LPCWSTR
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegReadBatchAddCommand';result := DllCall("CLUSAPI\ClusterRegReadBatchAddCommand"
, "Ptr", hRegReadBatch ; HREGREADBATCH
, "WStr", wzSubkeyName ; LPCWSTR
, "WStr", wzValueName ; LPCWSTR
, "Int") ; return: INT●ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName) = DLL("CLUSAPI.dll", "int ClusterRegReadBatchAddCommand(int, char*, char*)")
# 呼び出し: ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)
# hRegReadBatch : HREGREADBATCH -> "int"
# wzSubkeyName : LPCWSTR -> "char*"
# wzValueName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "clusapi" fn ClusterRegReadBatchAddCommand(
hRegReadBatch: isize, // HREGREADBATCH
wzSubkeyName: [*c]const u16, // LPCWSTR
wzValueName: [*c]const u16 // LPCWSTR
) callconv(std.os.windows.WINAPI) i32;proc ClusterRegReadBatchAddCommand(
hRegReadBatch: int, # HREGREADBATCH
wzSubkeyName: WideCString, # LPCWSTR
wzValueName: WideCString # LPCWSTR
): int32 {.importc: "ClusterRegReadBatchAddCommand", stdcall, dynlib: "CLUSAPI.dll".}pragma(lib, "clusapi");
extern(Windows)
int ClusterRegReadBatchAddCommand(
ptrdiff_t hRegReadBatch, // HREGREADBATCH
const(wchar)* wzSubkeyName, // LPCWSTR
const(wchar)* wzValueName // LPCWSTR
);ccall((:ClusterRegReadBatchAddCommand, "CLUSAPI.dll"), stdcall, Int32,
(Int, Cwstring, Cwstring),
hRegReadBatch, wzSubkeyName, wzValueName)
# hRegReadBatch : HREGREADBATCH -> Int
# wzSubkeyName : LPCWSTR -> Cwstring
# wzValueName : LPCWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ClusterRegReadBatchAddCommand(
intptr_t hRegReadBatch,
const uint16_t* wzSubkeyName,
const uint16_t* wzValueName);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)
-- hRegReadBatch : HREGREADBATCH
-- wzSubkeyName : LPCWSTR
-- wzValueName : LPCWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterRegReadBatchAddCommand = lib.func('__stdcall', 'ClusterRegReadBatchAddCommand', 'int32_t', ['intptr_t', 'str16', 'str16']);
// ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)
// hRegReadBatch : HREGREADBATCH -> 'intptr_t'
// wzSubkeyName : LPCWSTR -> 'str16'
// wzValueName : LPCWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CLUSAPI.dll", {
ClusterRegReadBatchAddCommand: { parameters: ["isize", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName)
// hRegReadBatch : HREGREADBATCH -> "isize"
// wzSubkeyName : LPCWSTR -> "buffer"
// wzValueName : LPCWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ClusterRegReadBatchAddCommand(
intptr_t hRegReadBatch,
const uint16_t* wzSubkeyName,
const uint16_t* wzValueName);
C, "CLUSAPI.dll");
// $ffi->ClusterRegReadBatchAddCommand(hRegReadBatch, wzSubkeyName, wzValueName);
// hRegReadBatch : HREGREADBATCH
// wzSubkeyName : LPCWSTR
// wzValueName : LPCWSTR
// 構造体/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);
int ClusterRegReadBatchAddCommand(
long hRegReadBatch, // HREGREADBATCH
WString wzSubkeyName, // LPCWSTR
WString wzValueName // LPCWSTR
);
}@[Link("clusapi")]
lib LibCLUSAPI
fun ClusterRegReadBatchAddCommand = ClusterRegReadBatchAddCommand(
hRegReadBatch : LibC::SSizeT, # HREGREADBATCH
wzSubkeyName : UInt16*, # LPCWSTR
wzValueName : UInt16* # LPCWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ClusterRegReadBatchAddCommandNative = Int32 Function(IntPtr, Pointer<Utf16>, Pointer<Utf16>);
typedef ClusterRegReadBatchAddCommandDart = int Function(int, Pointer<Utf16>, Pointer<Utf16>);
final ClusterRegReadBatchAddCommand = DynamicLibrary.open('CLUSAPI.dll')
.lookupFunction<ClusterRegReadBatchAddCommandNative, ClusterRegReadBatchAddCommandDart>('ClusterRegReadBatchAddCommand');
// hRegReadBatch : HREGREADBATCH -> IntPtr
// wzSubkeyName : LPCWSTR -> Pointer<Utf16>
// wzValueName : LPCWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ClusterRegReadBatchAddCommand(
hRegReadBatch: NativeInt; // HREGREADBATCH
wzSubkeyName: PWideChar; // LPCWSTR
wzValueName: PWideChar // LPCWSTR
): Integer; stdcall;
external 'CLUSAPI.dll' name 'ClusterRegReadBatchAddCommand';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ClusterRegReadBatchAddCommand"
c_ClusterRegReadBatchAddCommand :: CIntPtr -> CWString -> CWString -> IO Int32
-- hRegReadBatch : HREGREADBATCH -> CIntPtr
-- wzSubkeyName : LPCWSTR -> CWString
-- wzValueName : LPCWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let clusterregreadbatchaddcommand =
foreign "ClusterRegReadBatchAddCommand"
(intptr_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hRegReadBatch : HREGREADBATCH -> intptr_t *)
(* wzSubkeyName : LPCWSTR -> (ptr uint16_t) *)
(* wzValueName : LPCWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)
(cffi:defcfun ("ClusterRegReadBatchAddCommand" cluster-reg-read-batch-add-command :convention :stdcall) :int32
(h-reg-read-batch :int64) ; HREGREADBATCH
(wz-subkey-name (:string :encoding :utf-16le)) ; LPCWSTR
(wz-value-name (:string :encoding :utf-16le))) ; LPCWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ClusterRegReadBatchAddCommand = Win32::API::More->new('CLUSAPI',
'int ClusterRegReadBatchAddCommand(LPARAM hRegReadBatch, LPCWSTR wzSubkeyName, LPCWSTR wzValueName)');
# my $ret = $ClusterRegReadBatchAddCommand->Call($hRegReadBatch, $wzSubkeyName, $wzValueName);
# hRegReadBatch : HREGREADBATCH -> LPARAM
# wzSubkeyName : LPCWSTR -> LPCWSTR
# wzValueName : LPCWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。