Win32 API 日本語リファレンス
ホームNetworking.Clustering › ClusterRegBatchAddCommand

ClusterRegBatchAddCommand

関数
クラスタレジストリバッチにコマンドを追加する。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

// CLUSAPI.dll
#include <windows.h>

INT ClusterRegBatchAddCommand(
    HREGBATCH hRegBatch,
    CLUSTER_REG_COMMAND dwCommand,
    LPCWSTR wzName,   // optional
    DWORD dwOptions,
    const void* lpData,   // optional
    DWORD cbData
);

パラメーター

名前方向説明
hRegBatchHREGBATCHinコマンドを追加する対象のバッチハンドル。
dwCommandCLUSTER_REG_COMMANDin実行するレジストリ操作の種別を示すCLUSTER_REG_COMMAND列挙値。
wzNameLPCWSTRinoptional操作対象のキー名または値名を示すワイド文字列。
dwOptionsDWORDin値の型などコマンドのオプションを示すフラグ。
lpDatavoid*inoptionalコマンドで書き込むデータへのポインタ。不要ならNULL可。
cbDataDWORDinlpDataのサイズ(バイト)。

戻り値の型: INT

各言語での呼び出し定義

// CLUSAPI.dll
#include <windows.h>

INT ClusterRegBatchAddCommand(
    HREGBATCH hRegBatch,
    CLUSTER_REG_COMMAND dwCommand,
    LPCWSTR wzName,   // optional
    DWORD dwOptions,
    const void* lpData,   // optional
    DWORD cbData
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegBatchAddCommand(
    IntPtr hRegBatch,   // HREGBATCH
    int dwCommand,   // CLUSTER_REG_COMMAND
    [MarshalAs(UnmanagedType.LPWStr)] string wzName,   // LPCWSTR optional
    uint dwOptions,   // DWORD
    IntPtr lpData,   // void* optional
    uint cbData   // DWORD
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegBatchAddCommand(
    hRegBatch As IntPtr,   ' HREGBATCH
    dwCommand As Integer,   ' CLUSTER_REG_COMMAND
    <MarshalAs(UnmanagedType.LPWStr)> wzName As String,   ' LPCWSTR optional
    dwOptions As UInteger,   ' DWORD
    lpData As IntPtr,   ' void* optional
    cbData As UInteger   ' DWORD
) As Integer
End Function
' hRegBatch : HREGBATCH
' dwCommand : CLUSTER_REG_COMMAND
' wzName : LPCWSTR optional
' dwOptions : DWORD
' lpData : void* optional
' cbData : DWORD
Declare PtrSafe Function ClusterRegBatchAddCommand Lib "clusapi" ( _
    ByVal hRegBatch As LongPtr, _
    ByVal dwCommand As Long, _
    ByVal wzName As LongPtr, _
    ByVal dwOptions As Long, _
    ByVal lpData As LongPtr, _
    ByVal cbData As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegBatchAddCommand = ctypes.windll.clusapi.ClusterRegBatchAddCommand
ClusterRegBatchAddCommand.restype = ctypes.c_int
ClusterRegBatchAddCommand.argtypes = [
    ctypes.c_ssize_t,  # hRegBatch : HREGBATCH
    ctypes.c_int,  # dwCommand : CLUSTER_REG_COMMAND
    wintypes.LPCWSTR,  # wzName : LPCWSTR optional
    wintypes.DWORD,  # dwOptions : DWORD
    ctypes.POINTER(None),  # lpData : void* optional
    wintypes.DWORD,  # cbData : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegBatchAddCommand = Fiddle::Function.new(
  lib['ClusterRegBatchAddCommand'],
  [
    Fiddle::TYPE_INTPTR_T,  # hRegBatch : HREGBATCH
    Fiddle::TYPE_INT,  # dwCommand : CLUSTER_REG_COMMAND
    Fiddle::TYPE_VOIDP,  # wzName : LPCWSTR optional
    -Fiddle::TYPE_INT,  # dwOptions : DWORD
    Fiddle::TYPE_VOIDP,  # lpData : void* optional
    -Fiddle::TYPE_INT,  # cbData : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterRegBatchAddCommand(
        hRegBatch: isize,  // HREGBATCH
        dwCommand: i32,  // CLUSTER_REG_COMMAND
        wzName: *const u16,  // LPCWSTR optional
        dwOptions: u32,  // DWORD
        lpData: *const (),  // void* optional
        cbData: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegBatchAddCommand(IntPtr hRegBatch, int dwCommand, [MarshalAs(UnmanagedType.LPWStr)] string wzName, uint dwOptions, IntPtr lpData, uint cbData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegBatchAddCommand' -Namespace Win32 -PassThru
# $api::ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
#uselib "CLUSAPI.dll"
#func global ClusterRegBatchAddCommand "ClusterRegBatchAddCommand" sptr, sptr, sptr, sptr, sptr, sptr
; ClusterRegBatchAddCommand hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData   ; 戻り値は stat
; hRegBatch : HREGBATCH -> "sptr"
; dwCommand : CLUSTER_REG_COMMAND -> "sptr"
; wzName : LPCWSTR optional -> "sptr"
; dwOptions : DWORD -> "sptr"
; lpData : void* optional -> "sptr"
; cbData : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegBatchAddCommand "ClusterRegBatchAddCommand" sptr, int, wstr, int, sptr, int
; res = ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
; hRegBatch : HREGBATCH -> "sptr"
; dwCommand : CLUSTER_REG_COMMAND -> "int"
; wzName : LPCWSTR optional -> "wstr"
; dwOptions : DWORD -> "int"
; lpData : void* optional -> "sptr"
; cbData : DWORD -> "int"
; INT ClusterRegBatchAddCommand(HREGBATCH hRegBatch, CLUSTER_REG_COMMAND dwCommand, LPCWSTR wzName, DWORD dwOptions, void* lpData, DWORD cbData)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegBatchAddCommand "ClusterRegBatchAddCommand" intptr, int, wstr, int, intptr, int
; res = ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
; hRegBatch : HREGBATCH -> "intptr"
; dwCommand : CLUSTER_REG_COMMAND -> "int"
; wzName : LPCWSTR optional -> "wstr"
; dwOptions : DWORD -> "int"
; lpData : void* optional -> "intptr"
; cbData : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegBatchAddCommand = clusapi.NewProc("ClusterRegBatchAddCommand")
)

// hRegBatch (HREGBATCH), dwCommand (CLUSTER_REG_COMMAND), wzName (LPCWSTR optional), dwOptions (DWORD), lpData (void* optional), cbData (DWORD)
r1, _, err := procClusterRegBatchAddCommand.Call(
	uintptr(hRegBatch),
	uintptr(dwCommand),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(wzName))),
	uintptr(dwOptions),
	uintptr(lpData),
	uintptr(cbData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ClusterRegBatchAddCommand(
  hRegBatch: NativeInt;   // HREGBATCH
  dwCommand: Integer;   // CLUSTER_REG_COMMAND
  wzName: PWideChar;   // LPCWSTR optional
  dwOptions: DWORD;   // DWORD
  lpData: Pointer;   // void* optional
  cbData: DWORD   // DWORD
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegBatchAddCommand';
result := DllCall("CLUSAPI\ClusterRegBatchAddCommand"
    , "Ptr", hRegBatch   ; HREGBATCH
    , "Int", dwCommand   ; CLUSTER_REG_COMMAND
    , "WStr", wzName   ; LPCWSTR optional
    , "UInt", dwOptions   ; DWORD
    , "Ptr", lpData   ; void* optional
    , "UInt", cbData   ; DWORD
    , "Int")   ; return: INT
●ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData) = DLL("CLUSAPI.dll", "int ClusterRegBatchAddCommand(int, int, char*, dword, void*, dword)")
# 呼び出し: ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
# hRegBatch : HREGBATCH -> "int"
# dwCommand : CLUSTER_REG_COMMAND -> "int"
# wzName : LPCWSTR optional -> "char*"
# dwOptions : DWORD -> "dword"
# lpData : void* optional -> "void*"
# cbData : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "clusapi" fn ClusterRegBatchAddCommand(
    hRegBatch: isize, // HREGBATCH
    dwCommand: i32, // CLUSTER_REG_COMMAND
    wzName: [*c]const u16, // LPCWSTR optional
    dwOptions: u32, // DWORD
    lpData: ?*anyopaque, // void* optional
    cbData: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc ClusterRegBatchAddCommand(
    hRegBatch: int,  # HREGBATCH
    dwCommand: int32,  # CLUSTER_REG_COMMAND
    wzName: WideCString,  # LPCWSTR optional
    dwOptions: uint32,  # DWORD
    lpData: pointer,  # void* optional
    cbData: uint32  # DWORD
): int32 {.importc: "ClusterRegBatchAddCommand", stdcall, dynlib: "CLUSAPI.dll".}
pragma(lib, "clusapi");
extern(Windows)
int ClusterRegBatchAddCommand(
    ptrdiff_t hRegBatch,   // HREGBATCH
    int dwCommand,   // CLUSTER_REG_COMMAND
    const(wchar)* wzName,   // LPCWSTR optional
    uint dwOptions,   // DWORD
    void* lpData,   // void* optional
    uint cbData   // DWORD
);
ccall((:ClusterRegBatchAddCommand, "CLUSAPI.dll"), stdcall, Int32,
      (Int, Int32, Cwstring, UInt32, Ptr{Cvoid}, UInt32),
      hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
# hRegBatch : HREGBATCH -> Int
# dwCommand : CLUSTER_REG_COMMAND -> Int32
# wzName : LPCWSTR optional -> Cwstring
# dwOptions : DWORD -> UInt32
# lpData : void* optional -> Ptr{Cvoid}
# cbData : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ClusterRegBatchAddCommand(
    intptr_t hRegBatch,
    int32_t dwCommand,
    const uint16_t* wzName,
    uint32_t dwOptions,
    void* lpData,
    uint32_t cbData);
]]
local clusapi = ffi.load("clusapi")
-- clusapi.ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
-- hRegBatch : HREGBATCH
-- dwCommand : CLUSTER_REG_COMMAND
-- wzName : LPCWSTR optional
-- dwOptions : DWORD
-- lpData : void* optional
-- cbData : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('CLUSAPI.dll');
const ClusterRegBatchAddCommand = lib.func('__stdcall', 'ClusterRegBatchAddCommand', 'int32_t', ['intptr_t', 'int32_t', 'str16', 'uint32_t', 'void *', 'uint32_t']);
// ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
// hRegBatch : HREGBATCH -> 'intptr_t'
// dwCommand : CLUSTER_REG_COMMAND -> 'int32_t'
// wzName : LPCWSTR optional -> 'str16'
// dwOptions : DWORD -> 'uint32_t'
// lpData : void* optional -> 'void *'
// cbData : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("CLUSAPI.dll", {
  ClusterRegBatchAddCommand: { parameters: ["isize", "i32", "buffer", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData)
// hRegBatch : HREGBATCH -> "isize"
// dwCommand : CLUSTER_REG_COMMAND -> "i32"
// wzName : LPCWSTR optional -> "buffer"
// dwOptions : DWORD -> "u32"
// lpData : void* optional -> "pointer"
// cbData : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ClusterRegBatchAddCommand(
    intptr_t hRegBatch,
    int32_t dwCommand,
    const uint16_t* wzName,
    uint32_t dwOptions,
    void* lpData,
    uint32_t cbData);
C, "CLUSAPI.dll");
// $ffi->ClusterRegBatchAddCommand(hRegBatch, dwCommand, wzName, dwOptions, lpData, cbData);
// hRegBatch : HREGBATCH
// dwCommand : CLUSTER_REG_COMMAND
// wzName : LPCWSTR optional
// dwOptions : DWORD
// lpData : void* optional
// cbData : 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);
    int ClusterRegBatchAddCommand(
        long hRegBatch,   // HREGBATCH
        int dwCommand,   // CLUSTER_REG_COMMAND
        WString wzName,   // LPCWSTR optional
        int dwOptions,   // DWORD
        Pointer lpData,   // void* optional
        int cbData   // DWORD
    );
}
@[Link("clusapi")]
lib LibCLUSAPI
  fun ClusterRegBatchAddCommand = ClusterRegBatchAddCommand(
    hRegBatch : LibC::SSizeT,   # HREGBATCH
    dwCommand : Int32,   # CLUSTER_REG_COMMAND
    wzName : UInt16*,   # LPCWSTR optional
    dwOptions : UInt32,   # DWORD
    lpData : Void*,   # void* optional
    cbData : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ClusterRegBatchAddCommandNative = Int32 Function(IntPtr, Int32, Pointer<Utf16>, Uint32, Pointer<Void>, Uint32);
typedef ClusterRegBatchAddCommandDart = int Function(int, int, Pointer<Utf16>, int, Pointer<Void>, int);
final ClusterRegBatchAddCommand = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<ClusterRegBatchAddCommandNative, ClusterRegBatchAddCommandDart>('ClusterRegBatchAddCommand');
// hRegBatch : HREGBATCH -> IntPtr
// dwCommand : CLUSTER_REG_COMMAND -> Int32
// wzName : LPCWSTR optional -> Pointer<Utf16>
// dwOptions : DWORD -> Uint32
// lpData : void* optional -> Pointer<Void>
// cbData : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ClusterRegBatchAddCommand(
  hRegBatch: NativeInt;   // HREGBATCH
  dwCommand: Integer;   // CLUSTER_REG_COMMAND
  wzName: PWideChar;   // LPCWSTR optional
  dwOptions: DWORD;   // DWORD
  lpData: Pointer;   // void* optional
  cbData: DWORD   // DWORD
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegBatchAddCommand';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ClusterRegBatchAddCommand"
  c_ClusterRegBatchAddCommand :: CIntPtr -> Int32 -> CWString -> Word32 -> Ptr () -> Word32 -> IO Int32
-- hRegBatch : HREGBATCH -> CIntPtr
-- dwCommand : CLUSTER_REG_COMMAND -> Int32
-- wzName : LPCWSTR optional -> CWString
-- dwOptions : DWORD -> Word32
-- lpData : void* optional -> Ptr ()
-- cbData : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let clusterregbatchaddcommand =
  foreign "ClusterRegBatchAddCommand"
    (intptr_t @-> int32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* hRegBatch : HREGBATCH -> intptr_t *)
(* dwCommand : CLUSTER_REG_COMMAND -> int32_t *)
(* wzName : LPCWSTR optional -> (ptr uint16_t) *)
(* dwOptions : DWORD -> uint32_t *)
(* lpData : void* optional -> (ptr void) *)
(* cbData : 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 ("ClusterRegBatchAddCommand" cluster-reg-batch-add-command :convention :stdcall) :int32
  (h-reg-batch :int64)   ; HREGBATCH
  (dw-command :int32)   ; CLUSTER_REG_COMMAND
  (wz-name (:string :encoding :utf-16le))   ; LPCWSTR optional
  (dw-options :uint32)   ; DWORD
  (lp-data :pointer)   ; void* optional
  (cb-data :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ClusterRegBatchAddCommand = Win32::API::More->new('CLUSAPI',
    'int ClusterRegBatchAddCommand(LPARAM hRegBatch, int dwCommand, LPCWSTR wzName, DWORD dwOptions, LPVOID lpData, DWORD cbData)');
# my $ret = $ClusterRegBatchAddCommand->Call($hRegBatch, $dwCommand, $wzName, $dwOptions, $lpData, $cbData);
# hRegBatch : HREGBATCH -> LPARAM
# dwCommand : CLUSTER_REG_COMMAND -> int
# wzName : LPCWSTR optional -> LPCWSTR
# dwOptions : DWORD -> DWORD
# lpData : void* optional -> LPVOID
# cbData : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型