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

ClusterRegBatchReadCommand

関数
バッチ通知から次のコマンド内容を読み取る。
DLLCLUSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

INT ClusterRegBatchReadCommand(
    HREGBATCHNOTIFICATION hBatchNotification,
    CLUSTER_BATCH_COMMAND* pBatchCommand
);

パラメーター

名前方向説明
hBatchNotificationHREGBATCHNOTIFICATIONin読み取る対象のバッチ通知ハンドル。
pBatchCommandCLUSTER_BATCH_COMMAND*out読み取ったコマンド内容を受け取るCLUSTER_BATCH_COMMAND構造体ポインタ。

戻り値の型: INT

各言語での呼び出し定義

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

INT ClusterRegBatchReadCommand(
    HREGBATCHNOTIFICATION hBatchNotification,
    CLUSTER_BATCH_COMMAND* pBatchCommand
);
[DllImport("CLUSAPI.dll", ExactSpelling = true)]
static extern int ClusterRegBatchReadCommand(
    IntPtr hBatchNotification,   // HREGBATCHNOTIFICATION
    IntPtr pBatchCommand   // CLUSTER_BATCH_COMMAND* out
);
<DllImport("CLUSAPI.dll", ExactSpelling:=True)>
Public Shared Function ClusterRegBatchReadCommand(
    hBatchNotification As IntPtr,   ' HREGBATCHNOTIFICATION
    pBatchCommand As IntPtr   ' CLUSTER_BATCH_COMMAND* out
) As Integer
End Function
' hBatchNotification : HREGBATCHNOTIFICATION
' pBatchCommand : CLUSTER_BATCH_COMMAND* out
Declare PtrSafe Function ClusterRegBatchReadCommand Lib "clusapi" ( _
    ByVal hBatchNotification As LongPtr, _
    ByVal pBatchCommand As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ClusterRegBatchReadCommand = ctypes.windll.clusapi.ClusterRegBatchReadCommand
ClusterRegBatchReadCommand.restype = ctypes.c_int
ClusterRegBatchReadCommand.argtypes = [
    ctypes.c_ssize_t,  # hBatchNotification : HREGBATCHNOTIFICATION
    ctypes.c_void_p,  # pBatchCommand : CLUSTER_BATCH_COMMAND* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('CLUSAPI.dll')
ClusterRegBatchReadCommand = Fiddle::Function.new(
  lib['ClusterRegBatchReadCommand'],
  [
    Fiddle::TYPE_INTPTR_T,  # hBatchNotification : HREGBATCHNOTIFICATION
    Fiddle::TYPE_VOIDP,  # pBatchCommand : CLUSTER_BATCH_COMMAND* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "clusapi")]
extern "system" {
    fn ClusterRegBatchReadCommand(
        hBatchNotification: isize,  // HREGBATCHNOTIFICATION
        pBatchCommand: *mut CLUSTER_BATCH_COMMAND  // CLUSTER_BATCH_COMMAND* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("CLUSAPI.dll")]
public static extern int ClusterRegBatchReadCommand(IntPtr hBatchNotification, IntPtr pBatchCommand);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CLUSAPI_ClusterRegBatchReadCommand' -Namespace Win32 -PassThru
# $api::ClusterRegBatchReadCommand(hBatchNotification, pBatchCommand)
#uselib "CLUSAPI.dll"
#func global ClusterRegBatchReadCommand "ClusterRegBatchReadCommand" sptr, sptr
; ClusterRegBatchReadCommand hBatchNotification, varptr(pBatchCommand)   ; 戻り値は stat
; hBatchNotification : HREGBATCHNOTIFICATION -> "sptr"
; pBatchCommand : CLUSTER_BATCH_COMMAND* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegBatchReadCommand "ClusterRegBatchReadCommand" sptr, var
; res = ClusterRegBatchReadCommand(hBatchNotification, pBatchCommand)
; hBatchNotification : HREGBATCHNOTIFICATION -> "sptr"
; pBatchCommand : CLUSTER_BATCH_COMMAND* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT ClusterRegBatchReadCommand(HREGBATCHNOTIFICATION hBatchNotification, CLUSTER_BATCH_COMMAND* pBatchCommand)
#uselib "CLUSAPI.dll"
#cfunc global ClusterRegBatchReadCommand "ClusterRegBatchReadCommand" intptr, var
; res = ClusterRegBatchReadCommand(hBatchNotification, pBatchCommand)
; hBatchNotification : HREGBATCHNOTIFICATION -> "intptr"
; pBatchCommand : CLUSTER_BATCH_COMMAND* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	clusapi = windows.NewLazySystemDLL("CLUSAPI.dll")
	procClusterRegBatchReadCommand = clusapi.NewProc("ClusterRegBatchReadCommand")
)

// hBatchNotification (HREGBATCHNOTIFICATION), pBatchCommand (CLUSTER_BATCH_COMMAND* out)
r1, _, err := procClusterRegBatchReadCommand.Call(
	uintptr(hBatchNotification),
	uintptr(pBatchCommand),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ClusterRegBatchReadCommand(
  hBatchNotification: NativeInt;   // HREGBATCHNOTIFICATION
  pBatchCommand: Pointer   // CLUSTER_BATCH_COMMAND* out
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegBatchReadCommand';
result := DllCall("CLUSAPI\ClusterRegBatchReadCommand"
    , "Ptr", hBatchNotification   ; HREGBATCHNOTIFICATION
    , "Ptr", pBatchCommand   ; CLUSTER_BATCH_COMMAND* out
    , "Int")   ; return: INT
●ClusterRegBatchReadCommand(hBatchNotification, pBatchCommand) = DLL("CLUSAPI.dll", "int ClusterRegBatchReadCommand(int, void*)")
# 呼び出し: ClusterRegBatchReadCommand(hBatchNotification, pBatchCommand)
# hBatchNotification : HREGBATCHNOTIFICATION -> "int"
# pBatchCommand : CLUSTER_BATCH_COMMAND* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef ClusterRegBatchReadCommandNative = Int32 Function(IntPtr, Pointer<Void>);
typedef ClusterRegBatchReadCommandDart = int Function(int, Pointer<Void>);
final ClusterRegBatchReadCommand = DynamicLibrary.open('CLUSAPI.dll')
    .lookupFunction<ClusterRegBatchReadCommandNative, ClusterRegBatchReadCommandDart>('ClusterRegBatchReadCommand');
// hBatchNotification : HREGBATCHNOTIFICATION -> IntPtr
// pBatchCommand : CLUSTER_BATCH_COMMAND* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ClusterRegBatchReadCommand(
  hBatchNotification: NativeInt;   // HREGBATCHNOTIFICATION
  pBatchCommand: Pointer   // CLUSTER_BATCH_COMMAND* out
): Integer; stdcall;
  external 'CLUSAPI.dll' name 'ClusterRegBatchReadCommand';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ClusterRegBatchReadCommand"
  c_ClusterRegBatchReadCommand :: CIntPtr -> Ptr () -> IO Int32
-- hBatchNotification : HREGBATCHNOTIFICATION -> CIntPtr
-- pBatchCommand : CLUSTER_BATCH_COMMAND* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let clusterregbatchreadcommand =
  foreign "ClusterRegBatchReadCommand"
    (intptr_t @-> (ptr void) @-> returning int32_t)
(* hBatchNotification : HREGBATCHNOTIFICATION -> intptr_t *)
(* pBatchCommand : CLUSTER_BATCH_COMMAND* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library clusapi (t "CLUSAPI.dll"))
(cffi:use-foreign-library clusapi)

(cffi:defcfun ("ClusterRegBatchReadCommand" cluster-reg-batch-read-command :convention :stdcall) :int32
  (h-batch-notification :int64)   ; HREGBATCHNOTIFICATION
  (p-batch-command :pointer))   ; CLUSTER_BATCH_COMMAND* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ClusterRegBatchReadCommand = Win32::API::More->new('CLUSAPI',
    'int ClusterRegBatchReadCommand(LPARAM hBatchNotification, LPVOID pBatchCommand)');
# my $ret = $ClusterRegBatchReadCommand->Call($hBatchNotification, $pBatchCommand);
# hBatchNotification : HREGBATCHNOTIFICATION -> LPARAM
# pBatchCommand : CLUSTER_BATCH_COMMAND* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型