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

ResUtilGetEnvironmentWithNetName

関数
ネットワーク名を含む環境ブロックをリソースから取得する。
DLLRESUTILS.dll呼出規約winapiSetLastErrorあり対応OSwindowsserver2008

シグネチャ

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

void* ResUtilGetEnvironmentWithNetName(
    HRESOURCE hResource
);

パラメーター

名前方向説明
hResourceHRESOURCEin対象クラスターリソースのハンドル。このリソースのネットワーク名を含む環境ブロックを取得する。

戻り値の型: void*

各言語での呼び出し定義

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

void* ResUtilGetEnvironmentWithNetName(
    HRESOURCE hResource
);
[DllImport("RESUTILS.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr ResUtilGetEnvironmentWithNetName(
    IntPtr hResource   // HRESOURCE
);
<DllImport("RESUTILS.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ResUtilGetEnvironmentWithNetName(
    hResource As IntPtr   ' HRESOURCE
) As IntPtr
End Function
' hResource : HRESOURCE
Declare PtrSafe Function ResUtilGetEnvironmentWithNetName Lib "resutils" ( _
    ByVal hResource As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ResUtilGetEnvironmentWithNetName = ctypes.windll.resutils.ResUtilGetEnvironmentWithNetName
ResUtilGetEnvironmentWithNetName.restype = ctypes.c_void_p
ResUtilGetEnvironmentWithNetName.argtypes = [
    ctypes.c_ssize_t,  # hResource : HRESOURCE
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilGetEnvironmentWithNetName = Fiddle::Function.new(
  lib['ResUtilGetEnvironmentWithNetName'],
  [
    Fiddle::TYPE_INTPTR_T,  # hResource : HRESOURCE
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "resutils")]
extern "system" {
    fn ResUtilGetEnvironmentWithNetName(
        hResource: isize  // HRESOURCE
    ) -> *mut ();
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RESUTILS.dll", SetLastError = true)]
public static extern IntPtr ResUtilGetEnvironmentWithNetName(IntPtr hResource);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilGetEnvironmentWithNetName' -Namespace Win32 -PassThru
# $api::ResUtilGetEnvironmentWithNetName(hResource)
#uselib "RESUTILS.dll"
#func global ResUtilGetEnvironmentWithNetName "ResUtilGetEnvironmentWithNetName" sptr
; ResUtilGetEnvironmentWithNetName hResource   ; 戻り値は stat
; hResource : HRESOURCE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RESUTILS.dll"
#cfunc global ResUtilGetEnvironmentWithNetName "ResUtilGetEnvironmentWithNetName" sptr
; res = ResUtilGetEnvironmentWithNetName(hResource)
; hResource : HRESOURCE -> "sptr"
; void* ResUtilGetEnvironmentWithNetName(HRESOURCE hResource)
#uselib "RESUTILS.dll"
#cfunc global ResUtilGetEnvironmentWithNetName "ResUtilGetEnvironmentWithNetName" intptr
; res = ResUtilGetEnvironmentWithNetName(hResource)
; hResource : HRESOURCE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	resutils = windows.NewLazySystemDLL("RESUTILS.dll")
	procResUtilGetEnvironmentWithNetName = resutils.NewProc("ResUtilGetEnvironmentWithNetName")
)

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

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

typedef ResUtilGetEnvironmentWithNetNameNative = Pointer<Void> Function(IntPtr);
typedef ResUtilGetEnvironmentWithNetNameDart = Pointer<Void> Function(int);
final ResUtilGetEnvironmentWithNetName = DynamicLibrary.open('RESUTILS.dll')
    .lookupFunction<ResUtilGetEnvironmentWithNetNameNative, ResUtilGetEnvironmentWithNetNameDart>('ResUtilGetEnvironmentWithNetName');
// hResource : HRESOURCE -> IntPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ResUtilGetEnvironmentWithNetName(
  hResource: NativeInt   // HRESOURCE
): Pointer; stdcall;
  external 'RESUTILS.dll' name 'ResUtilGetEnvironmentWithNetName';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ResUtilGetEnvironmentWithNetName"
  c_ResUtilGetEnvironmentWithNetName :: CIntPtr -> IO (Ptr ())
-- hResource : HRESOURCE -> CIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let resutilgetenvironmentwithnetname =
  foreign "ResUtilGetEnvironmentWithNetName"
    (intptr_t @-> returning (ptr void))
(* hResource : HRESOURCE -> intptr_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)

(cffi:defcfun ("ResUtilGetEnvironmentWithNetName" res-util-get-environment-with-net-name :convention :stdcall) :pointer
  (h-resource :int64))   ; HRESOURCE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ResUtilGetEnvironmentWithNetName = Win32::API::More->new('RESUTILS',
    'LPVOID ResUtilGetEnvironmentWithNetName(LPARAM hResource)');
# my $ret = $ResUtilGetEnvironmentWithNetName->Call($hResource);
# hResource : HRESOURCE -> LPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。