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

ResUtilDupGroup

関数
クラスターグループのハンドルを複製して返す。
DLLRESUTILS.dll呼出規約winapi

シグネチャ

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

DWORD ResUtilDupGroup(
    HGROUP group,
    HGROUP* copy
);

パラメーター

名前方向説明
groupHGROUPin複製元となるクラスターグループのハンドル。
copyHGROUP*inout複製された新しいグループハンドルを受け取るポインター。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ResUtilDupGroup(
    HGROUP group,
    HGROUP* copy
);
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilDupGroup(
    IntPtr group,   // HGROUP
    ref IntPtr copy   // HGROUP* in/out
);
<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilDupGroup(
    group As IntPtr,   ' HGROUP
    ByRef copy As IntPtr   ' HGROUP* in/out
) As UInteger
End Function
' group : HGROUP
' copy : HGROUP* in/out
Declare PtrSafe Function ResUtilDupGroup Lib "resutils" ( _
    ByVal group As LongPtr, _
    ByRef copy As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilDupGroup = ctypes.windll.resutils.ResUtilDupGroup
ResUtilDupGroup.restype = wintypes.DWORD
ResUtilDupGroup.argtypes = [
    ctypes.c_ssize_t,  # group : HGROUP
    ctypes.c_void_p,  # copy : HGROUP* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilDupGroup = resutils.NewProc("ResUtilDupGroup")
)

// group (HGROUP), copy (HGROUP* in/out)
r1, _, err := procResUtilDupGroup.Call(
	uintptr(group),
	uintptr(copy),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function ResUtilDupGroup(
  group: NativeInt;   // HGROUP
  copy: Pointer   // HGROUP* in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilDupGroup';
result := DllCall("RESUTILS\ResUtilDupGroup"
    , "Ptr", group   ; HGROUP
    , "Ptr", copy   ; HGROUP* in/out
    , "UInt")   ; return: DWORD
●ResUtilDupGroup(group, copy) = DLL("RESUTILS.dll", "dword ResUtilDupGroup(int, void*)")
# 呼び出し: ResUtilDupGroup(group, copy)
# group : HGROUP -> "int"
# copy : HGROUP* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef ResUtilDupGroupNative = Uint32 Function(IntPtr, Pointer<IntPtr>);
typedef ResUtilDupGroupDart = int Function(int, Pointer<IntPtr>);
final ResUtilDupGroup = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilDupGroupNative, ResUtilDupGroupDart>('ResUtilDupGroup');
// group : HGROUP -> IntPtr
// copy : HGROUP* in/out -> Pointer<IntPtr>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilDupGroup(
  group: NativeInt;   // HGROUP
  copy: Pointer   // HGROUP* in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilDupGroup';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilDupGroup"
  c_ResUtilDupGroup :: CIntPtr -> Ptr CIntPtr -> IO Word32
-- group : HGROUP -> CIntPtr
-- copy : HGROUP* in/out -> Ptr CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutildupgroup =
  foreign "ResUtilDupGroup"
    (intptr_t @-> (ptr intptr_t) @-> returning uint32_t)
(* group : HGROUP -> intptr_t *)
(* copy : HGROUP* in/out -> (ptr intptr_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilDupGroup" res-util-dup-group :convention :stdcall) :uint32
  (group :int64)   ; HGROUP
  (copy :pointer))   ; HGROUP* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilDupGroup = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilDupGroup(LPARAM group, LPVOID copy)');
# my $ret = $ResUtilDupGroup->Call($group, $copy);
# group : HGROUP -> LPARAM
# copy : HGROUP* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。