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

ResUtilGetResourceDependentIPAddressProps

関数
依存先IPアドレスリソースのアドレス情報を取得する。
DLLRESUTILS.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD ResUtilGetResourceDependentIPAddressProps(
    HRESOURCE hResource,
    LPWSTR pszAddress,
    DWORD* pcchAddress,
    LPWSTR pszSubnetMask,
    DWORD* pcchSubnetMask,
    LPWSTR pszNetwork,
    DWORD* pcchNetwork
);

パラメーター

名前方向説明
hResourceHRESOURCEin依存先のIPアドレスリソースを持つ対象リソースのハンドル。
pszAddressLPWSTRout取得したIPアドレス文字列を受け取るバッファー。NULLでサイズ問い合わせ。
pcchAddressDWORD*inoutpszAddressバッファーの文字数を入出力する変数へのポインター。
pszSubnetMaskLPWSTRout取得したサブネットマスク文字列を受け取るバッファー。NULL可。
pcchSubnetMaskDWORD*inoutpszSubnetMaskバッファーの文字数を入出力する変数へのポインター。
pszNetworkLPWSTRout取得したネットワーク名文字列を受け取るバッファー。NULL可。
pcchNetworkDWORD*inoutpszNetworkバッファーの文字数を入出力する変数へのポインター。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD ResUtilGetResourceDependentIPAddressProps(
    HRESOURCE hResource,
    LPWSTR pszAddress,
    DWORD* pcchAddress,
    LPWSTR pszSubnetMask,
    DWORD* pcchSubnetMask,
    LPWSTR pszNetwork,
    DWORD* pcchNetwork
);
[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilGetResourceDependentIPAddressProps(
    IntPtr hResource,   // HRESOURCE
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszAddress,   // LPWSTR out
    ref uint pcchAddress,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszSubnetMask,   // LPWSTR out
    ref uint pcchSubnetMask,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszNetwork,   // LPWSTR out
    ref uint pcchNetwork   // DWORD* in/out
);
<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilGetResourceDependentIPAddressProps(
    hResource As IntPtr,   ' HRESOURCE
    <MarshalAs(UnmanagedType.LPWStr)> pszAddress As System.Text.StringBuilder,   ' LPWSTR out
    ByRef pcchAddress As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pszSubnetMask As System.Text.StringBuilder,   ' LPWSTR out
    ByRef pcchSubnetMask As UInteger,   ' DWORD* in/out
    <MarshalAs(UnmanagedType.LPWStr)> pszNetwork As System.Text.StringBuilder,   ' LPWSTR out
    ByRef pcchNetwork As UInteger   ' DWORD* in/out
) As UInteger
End Function
' hResource : HRESOURCE
' pszAddress : LPWSTR out
' pcchAddress : DWORD* in/out
' pszSubnetMask : LPWSTR out
' pcchSubnetMask : DWORD* in/out
' pszNetwork : LPWSTR out
' pcchNetwork : DWORD* in/out
Declare PtrSafe Function ResUtilGetResourceDependentIPAddressProps Lib "resutils" ( _
    ByVal hResource As LongPtr, _
    ByVal pszAddress As LongPtr, _
    ByRef pcchAddress As Long, _
    ByVal pszSubnetMask As LongPtr, _
    ByRef pcchSubnetMask As Long, _
    ByVal pszNetwork As LongPtr, _
    ByRef pcchNetwork As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilGetResourceDependentIPAddressProps = ctypes.windll.resutils.ResUtilGetResourceDependentIPAddressProps
ResUtilGetResourceDependentIPAddressProps.restype = wintypes.DWORD
ResUtilGetResourceDependentIPAddressProps.argtypes = [
    ctypes.c_ssize_t,  # hResource : HRESOURCE
    wintypes.LPWSTR,  # pszAddress : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchAddress : DWORD* in/out
    wintypes.LPWSTR,  # pszSubnetMask : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchSubnetMask : DWORD* in/out
    wintypes.LPWSTR,  # pszNetwork : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # pcchNetwork : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilGetResourceDependentIPAddressProps = resutils.NewProc("ResUtilGetResourceDependentIPAddressProps")
)

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

extern "resutils" fn ResUtilGetResourceDependentIPAddressProps(
    hResource: isize, // HRESOURCE
    pszAddress: [*c]u16, // LPWSTR out
    pcchAddress: [*c]u32, // DWORD* in/out
    pszSubnetMask: [*c]u16, // LPWSTR out
    pcchSubnetMask: [*c]u32, // DWORD* in/out
    pszNetwork: [*c]u16, // LPWSTR out
    pcchNetwork: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) u32;
proc ResUtilGetResourceDependentIPAddressProps(
    hResource: int,  # HRESOURCE
    pszAddress: ptr uint16,  # LPWSTR out
    pcchAddress: ptr uint32,  # DWORD* in/out
    pszSubnetMask: ptr uint16,  # LPWSTR out
    pcchSubnetMask: ptr uint32,  # DWORD* in/out
    pszNetwork: ptr uint16,  # LPWSTR out
    pcchNetwork: ptr uint32  # DWORD* in/out
): uint32 {.importc: "ResUtilGetResourceDependentIPAddressProps", stdcall, dynlib: "RESUTILS.dll".}
pragma(lib, "resutils");
extern(Windows)
uint ResUtilGetResourceDependentIPAddressProps(
    ptrdiff_t hResource,   // HRESOURCE
    wchar* pszAddress,   // LPWSTR out
    uint* pcchAddress,   // DWORD* in/out
    wchar* pszSubnetMask,   // LPWSTR out
    uint* pcchSubnetMask,   // DWORD* in/out
    wchar* pszNetwork,   // LPWSTR out
    uint* pcchNetwork   // DWORD* in/out
);
ccall((:ResUtilGetResourceDependentIPAddressProps, "RESUTILS.dll"), stdcall, UInt32,
      (Int, Ptr{UInt16}, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt32}),
      hResource, pszAddress, pcchAddress, pszSubnetMask, pcchSubnetMask, pszNetwork, pcchNetwork)
# hResource : HRESOURCE -> Int
# pszAddress : LPWSTR out -> Ptr{UInt16}
# pcchAddress : DWORD* in/out -> Ptr{UInt32}
# pszSubnetMask : LPWSTR out -> Ptr{UInt16}
# pcchSubnetMask : DWORD* in/out -> Ptr{UInt32}
# pszNetwork : LPWSTR out -> Ptr{UInt16}
# pcchNetwork : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilGetResourceDependentIPAddressProps(
    intptr_t hResource,
    uint16_t* pszAddress,
    uint32_t* pcchAddress,
    uint16_t* pszSubnetMask,
    uint32_t* pcchSubnetMask,
    uint16_t* pszNetwork,
    uint32_t* pcchNetwork);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilGetResourceDependentIPAddressProps(hResource, pszAddress, pcchAddress, pszSubnetMask, pcchSubnetMask, pszNetwork, pcchNetwork)
-- hResource : HRESOURCE
-- pszAddress : LPWSTR out
-- pcchAddress : DWORD* in/out
-- pszSubnetMask : LPWSTR out
-- pcchSubnetMask : DWORD* in/out
-- pszNetwork : LPWSTR out
-- pcchNetwork : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilGetResourceDependentIPAddressProps = lib.func('__stdcall', 'ResUtilGetResourceDependentIPAddressProps', 'uint32_t', ['intptr_t', 'uint16_t *', 'uint32_t *', 'uint16_t *', 'uint32_t *', 'uint16_t *', 'uint32_t *']);
// ResUtilGetResourceDependentIPAddressProps(hResource, pszAddress, pcchAddress, pszSubnetMask, pcchSubnetMask, pszNetwork, pcchNetwork)
// hResource : HRESOURCE -> 'intptr_t'
// pszAddress : LPWSTR out -> 'uint16_t *'
// pcchAddress : DWORD* in/out -> 'uint32_t *'
// pszSubnetMask : LPWSTR out -> 'uint16_t *'
// pcchSubnetMask : DWORD* in/out -> 'uint32_t *'
// pszNetwork : LPWSTR out -> 'uint16_t *'
// pcchNetwork : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RESUTILS.dll", {
  ResUtilGetResourceDependentIPAddressProps: { parameters: ["isize", "buffer", "pointer", "buffer", "pointer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilGetResourceDependentIPAddressProps(hResource, pszAddress, pcchAddress, pszSubnetMask, pcchSubnetMask, pszNetwork, pcchNetwork)
// hResource : HRESOURCE -> "isize"
// pszAddress : LPWSTR out -> "buffer"
// pcchAddress : DWORD* in/out -> "pointer"
// pszSubnetMask : LPWSTR out -> "buffer"
// pcchSubnetMask : DWORD* in/out -> "pointer"
// pszNetwork : LPWSTR out -> "buffer"
// pcchNetwork : DWORD* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilGetResourceDependentIPAddressProps(
    intptr_t hResource,
    uint16_t* pszAddress,
    uint32_t* pcchAddress,
    uint16_t* pszSubnetMask,
    uint32_t* pcchSubnetMask,
    uint16_t* pszNetwork,
    uint32_t* pcchNetwork);
C, "RESUTILS.dll");
// $ffi->ResUtilGetResourceDependentIPAddressProps(hResource, pszAddress, pcchAddress, pszSubnetMask, pcchSubnetMask, pszNetwork, pcchNetwork);
// hResource : HRESOURCE
// pszAddress : LPWSTR out
// pcchAddress : DWORD* in/out
// pszSubnetMask : LPWSTR out
// pcchSubnetMask : DWORD* in/out
// pszNetwork : LPWSTR out
// pcchNetwork : DWORD* 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 ResUtilGetResourceDependentIPAddressProps(
        long hResource,   // HRESOURCE
        char[] pszAddress,   // LPWSTR out
        IntByReference pcchAddress,   // DWORD* in/out
        char[] pszSubnetMask,   // LPWSTR out
        IntByReference pcchSubnetMask,   // DWORD* in/out
        char[] pszNetwork,   // LPWSTR out
        IntByReference pcchNetwork   // DWORD* in/out
    );
}
@[Link("resutils")]
lib LibRESUTILS
  fun ResUtilGetResourceDependentIPAddressProps = ResUtilGetResourceDependentIPAddressProps(
    hResource : LibC::SSizeT,   # HRESOURCE
    pszAddress : UInt16*,   # LPWSTR out
    pcchAddress : UInt32*,   # DWORD* in/out
    pszSubnetMask : UInt16*,   # LPWSTR out
    pcchSubnetMask : UInt32*,   # DWORD* in/out
    pszNetwork : UInt16*,   # LPWSTR out
    pcchNetwork : UInt32*   # DWORD* 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 ResUtilGetResourceDependentIPAddressPropsNative = Uint32 Function(IntPtr, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>);
typedef ResUtilGetResourceDependentIPAddressPropsDart = int Function(int, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>);
final ResUtilGetResourceDependentIPAddressProps = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilGetResourceDependentIPAddressPropsNative, ResUtilGetResourceDependentIPAddressPropsDart>('ResUtilGetResourceDependentIPAddressProps');
// hResource : HRESOURCE -> IntPtr
// pszAddress : LPWSTR out -> Pointer<Utf16>
// pcchAddress : DWORD* in/out -> Pointer<Uint32>
// pszSubnetMask : LPWSTR out -> Pointer<Utf16>
// pcchSubnetMask : DWORD* in/out -> Pointer<Uint32>
// pszNetwork : LPWSTR out -> Pointer<Utf16>
// pcchNetwork : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilGetResourceDependentIPAddressProps(
  hResource: NativeInt;   // HRESOURCE
  pszAddress: PWideChar;   // LPWSTR out
  pcchAddress: Pointer;   // DWORD* in/out
  pszSubnetMask: PWideChar;   // LPWSTR out
  pcchSubnetMask: Pointer;   // DWORD* in/out
  pszNetwork: PWideChar;   // LPWSTR out
  pcchNetwork: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'RESUTILS.dll' name 'ResUtilGetResourceDependentIPAddressProps';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilGetResourceDependentIPAddressProps"
  c_ResUtilGetResourceDependentIPAddressProps :: CIntPtr -> CWString -> Ptr Word32 -> CWString -> Ptr Word32 -> CWString -> Ptr Word32 -> IO Word32
-- hResource : HRESOURCE -> CIntPtr
-- pszAddress : LPWSTR out -> CWString
-- pcchAddress : DWORD* in/out -> Ptr Word32
-- pszSubnetMask : LPWSTR out -> CWString
-- pcchSubnetMask : DWORD* in/out -> Ptr Word32
-- pszNetwork : LPWSTR out -> CWString
-- pcchNetwork : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutilgetresourcedependentipaddressprops =
  foreign "ResUtilGetResourceDependentIPAddressProps"
    (intptr_t @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* hResource : HRESOURCE -> intptr_t *)
(* pszAddress : LPWSTR out -> (ptr uint16_t) *)
(* pcchAddress : DWORD* in/out -> (ptr uint32_t) *)
(* pszSubnetMask : LPWSTR out -> (ptr uint16_t) *)
(* pcchSubnetMask : DWORD* in/out -> (ptr uint32_t) *)
(* pszNetwork : LPWSTR out -> (ptr uint16_t) *)
(* pcchNetwork : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilGetResourceDependentIPAddressProps" res-util-get-resource-dependent-ipaddress-props :convention :stdcall) :uint32
  (h-resource :int64)   ; HRESOURCE
  (psz-address :pointer)   ; LPWSTR out
  (pcch-address :pointer)   ; DWORD* in/out
  (psz-subnet-mask :pointer)   ; LPWSTR out
  (pcch-subnet-mask :pointer)   ; DWORD* in/out
  (psz-network :pointer)   ; LPWSTR out
  (pcch-network :pointer))   ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilGetResourceDependentIPAddressProps = Win32::API::More->new('RESUTILS',
    'DWORD ResUtilGetResourceDependentIPAddressProps(LPARAM hResource, LPWSTR pszAddress, LPVOID pcchAddress, LPWSTR pszSubnetMask, LPVOID pcchSubnetMask, LPWSTR pszNetwork, LPVOID pcchNetwork)');
# my $ret = $ResUtilGetResourceDependentIPAddressProps->Call($hResource, $pszAddress, $pcchAddress, $pszSubnetMask, $pcchSubnetMask, $pszNetwork, $pcchNetwork);
# hResource : HRESOURCE -> LPARAM
# pszAddress : LPWSTR out -> LPWSTR
# pcchAddress : DWORD* in/out -> LPVOID
# pszSubnetMask : LPWSTR out -> LPWSTR
# pcchSubnetMask : DWORD* in/out -> LPVOID
# pszNetwork : LPWSTR out -> LPWSTR
# pcchNetwork : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。