Win32 API 日本語リファレンス
ホームNetworkManagement.WNet › WNetGetResourceInformationW

WNetGetResourceInformationW

関数
指定したネットワークリソースの詳細情報を取得する(Unicode版)。
DLLMPR.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// MPR.dll  (Unicode / -W)
#include <windows.h>

WIN32_ERROR WNetGetResourceInformationW(
    NETRESOURCEW* lpNetResource,
    void* lpBuffer,
    DWORD* lpcbBuffer,
    LPWSTR* lplpSystem
);

パラメーター

名前方向
lpNetResourceNETRESOURCEW*in
lpBuffervoid*out
lpcbBufferDWORD*inout
lplpSystemLPWSTR*out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// MPR.dll  (Unicode / -W)
#include <windows.h>

WIN32_ERROR WNetGetResourceInformationW(
    NETRESOURCEW* lpNetResource,
    void* lpBuffer,
    DWORD* lpcbBuffer,
    LPWSTR* lplpSystem
);
[DllImport("MPR.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint WNetGetResourceInformationW(
    IntPtr lpNetResource,   // NETRESOURCEW*
    IntPtr lpBuffer,   // void* out
    ref uint lpcbBuffer,   // DWORD* in/out
    IntPtr lplpSystem   // LPWSTR* out
);
<DllImport("MPR.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function WNetGetResourceInformationW(
    lpNetResource As IntPtr,   ' NETRESOURCEW*
    lpBuffer As IntPtr,   ' void* out
    ByRef lpcbBuffer As UInteger,   ' DWORD* in/out
    lplpSystem As IntPtr   ' LPWSTR* out
) As UInteger
End Function
' lpNetResource : NETRESOURCEW*
' lpBuffer : void* out
' lpcbBuffer : DWORD* in/out
' lplpSystem : LPWSTR* out
Declare PtrSafe Function WNetGetResourceInformationW Lib "mpr" ( _
    ByVal lpNetResource As LongPtr, _
    ByVal lpBuffer As LongPtr, _
    ByRef lpcbBuffer As Long, _
    ByVal lplpSystem As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WNetGetResourceInformationW = ctypes.windll.mpr.WNetGetResourceInformationW
WNetGetResourceInformationW.restype = wintypes.DWORD
WNetGetResourceInformationW.argtypes = [
    ctypes.c_void_p,  # lpNetResource : NETRESOURCEW*
    ctypes.POINTER(None),  # lpBuffer : void* out
    ctypes.POINTER(wintypes.DWORD),  # lpcbBuffer : DWORD* in/out
    ctypes.c_void_p,  # lplpSystem : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MPR.dll')
WNetGetResourceInformationW = Fiddle::Function.new(
  lib['WNetGetResourceInformationW'],
  [
    Fiddle::TYPE_VOIDP,  # lpNetResource : NETRESOURCEW*
    Fiddle::TYPE_VOIDP,  # lpBuffer : void* out
    Fiddle::TYPE_VOIDP,  # lpcbBuffer : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # lplpSystem : LPWSTR* out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "mpr")]
extern "system" {
    fn WNetGetResourceInformationW(
        lpNetResource: *mut NETRESOURCEW,  // NETRESOURCEW*
        lpBuffer: *mut (),  // void* out
        lpcbBuffer: *mut u32,  // DWORD* in/out
        lplpSystem: *mut *mut u16  // LPWSTR* out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MPR.dll", CharSet = CharSet.Unicode)]
public static extern uint WNetGetResourceInformationW(IntPtr lpNetResource, IntPtr lpBuffer, ref uint lpcbBuffer, IntPtr lplpSystem);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPR_WNetGetResourceInformationW' -Namespace Win32 -PassThru
# $api::WNetGetResourceInformationW(lpNetResource, lpBuffer, lpcbBuffer, lplpSystem)
#uselib "MPR.dll"
#func global WNetGetResourceInformationW "WNetGetResourceInformationW" wptr, wptr, wptr, wptr
; WNetGetResourceInformationW varptr(lpNetResource), lpBuffer, varptr(lpcbBuffer), varptr(lplpSystem)   ; 戻り値は stat
; lpNetResource : NETRESOURCEW* -> "wptr"
; lpBuffer : void* out -> "wptr"
; lpcbBuffer : DWORD* in/out -> "wptr"
; lplpSystem : LPWSTR* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MPR.dll"
#cfunc global WNetGetResourceInformationW "WNetGetResourceInformationW" var, sptr, var, var
; res = WNetGetResourceInformationW(lpNetResource, lpBuffer, lpcbBuffer, lplpSystem)
; lpNetResource : NETRESOURCEW* -> "var"
; lpBuffer : void* out -> "sptr"
; lpcbBuffer : DWORD* in/out -> "var"
; lplpSystem : LPWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR WNetGetResourceInformationW(NETRESOURCEW* lpNetResource, void* lpBuffer, DWORD* lpcbBuffer, LPWSTR* lplpSystem)
#uselib "MPR.dll"
#cfunc global WNetGetResourceInformationW "WNetGetResourceInformationW" var, intptr, var, var
; res = WNetGetResourceInformationW(lpNetResource, lpBuffer, lpcbBuffer, lplpSystem)
; lpNetResource : NETRESOURCEW* -> "var"
; lpBuffer : void* out -> "intptr"
; lpcbBuffer : DWORD* in/out -> "var"
; lplpSystem : LPWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mpr = windows.NewLazySystemDLL("MPR.dll")
	procWNetGetResourceInformationW = mpr.NewProc("WNetGetResourceInformationW")
)

// lpNetResource (NETRESOURCEW*), lpBuffer (void* out), lpcbBuffer (DWORD* in/out), lplpSystem (LPWSTR* out)
r1, _, err := procWNetGetResourceInformationW.Call(
	uintptr(lpNetResource),
	uintptr(lpBuffer),
	uintptr(lpcbBuffer),
	uintptr(lplpSystem),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function WNetGetResourceInformationW(
  lpNetResource: Pointer;   // NETRESOURCEW*
  lpBuffer: Pointer;   // void* out
  lpcbBuffer: Pointer;   // DWORD* in/out
  lplpSystem: PPWideChar   // LPWSTR* out
): DWORD; stdcall;
  external 'MPR.dll' name 'WNetGetResourceInformationW';
result := DllCall("MPR\WNetGetResourceInformationW"
    , "Ptr", lpNetResource   ; NETRESOURCEW*
    , "Ptr", lpBuffer   ; void* out
    , "Ptr", lpcbBuffer   ; DWORD* in/out
    , "Ptr", lplpSystem   ; LPWSTR* out
    , "UInt")   ; return: WIN32_ERROR
●WNetGetResourceInformationW(lpNetResource, lpBuffer, lpcbBuffer, lplpSystem) = DLL("MPR.dll", "dword WNetGetResourceInformationW(void*, void*, void*, void*)")
# 呼び出し: WNetGetResourceInformationW(lpNetResource, lpBuffer, lpcbBuffer, lplpSystem)
# lpNetResource : NETRESOURCEW* -> "void*"
# lpBuffer : void* out -> "void*"
# lpcbBuffer : DWORD* in/out -> "void*"
# lplpSystem : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。