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

WNetGetResourceParentA

関数
ネットワークリソースの親リソース情報を取得する(ANSI版)。
DLLMPR.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// MPR.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR WNetGetResourceParentA(
    NETRESOURCEA* lpNetResource,
    void* lpBuffer,
    DWORD* lpcbBuffer
);

パラメーター

名前方向
lpNetResourceNETRESOURCEA*in
lpBuffervoid*out
lpcbBufferDWORD*inout

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// MPR.dll  (ANSI / -A)
#include <windows.h>

WIN32_ERROR WNetGetResourceParentA(
    NETRESOURCEA* lpNetResource,
    void* lpBuffer,
    DWORD* lpcbBuffer
);
[DllImport("MPR.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint WNetGetResourceParentA(
    IntPtr lpNetResource,   // NETRESOURCEA*
    IntPtr lpBuffer,   // void* out
    ref uint lpcbBuffer   // DWORD* in/out
);
<DllImport("MPR.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function WNetGetResourceParentA(
    lpNetResource As IntPtr,   ' NETRESOURCEA*
    lpBuffer As IntPtr,   ' void* out
    ByRef lpcbBuffer As UInteger   ' DWORD* in/out
) As UInteger
End Function
' lpNetResource : NETRESOURCEA*
' lpBuffer : void* out
' lpcbBuffer : DWORD* in/out
Declare PtrSafe Function WNetGetResourceParentA Lib "mpr" ( _
    ByVal lpNetResource As LongPtr, _
    ByVal lpBuffer As LongPtr, _
    ByRef lpcbBuffer As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	mpr = windows.NewLazySystemDLL("MPR.dll")
	procWNetGetResourceParentA = mpr.NewProc("WNetGetResourceParentA")
)

// lpNetResource (NETRESOURCEA*), lpBuffer (void* out), lpcbBuffer (DWORD* in/out)
r1, _, err := procWNetGetResourceParentA.Call(
	uintptr(lpNetResource),
	uintptr(lpBuffer),
	uintptr(lpcbBuffer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function WNetGetResourceParentA(
  lpNetResource: Pointer;   // NETRESOURCEA*
  lpBuffer: Pointer;   // void* out
  lpcbBuffer: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'MPR.dll' name 'WNetGetResourceParentA';
result := DllCall("MPR\WNetGetResourceParentA"
    , "Ptr", lpNetResource   ; NETRESOURCEA*
    , "Ptr", lpBuffer   ; void* out
    , "Ptr", lpcbBuffer   ; DWORD* in/out
    , "UInt")   ; return: WIN32_ERROR
●WNetGetResourceParentA(lpNetResource, lpBuffer, lpcbBuffer) = DLL("MPR.dll", "dword WNetGetResourceParentA(void*, void*, void*)")
# 呼び出し: WNetGetResourceParentA(lpNetResource, lpBuffer, lpcbBuffer)
# lpNetResource : NETRESOURCEA* -> "void*"
# lpBuffer : void* out -> "void*"
# lpcbBuffer : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。