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

NPGetUniversalName

関数
ローカルパスのUNC汎用名をプロバイダーから取得する。
DLLdavclnt.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD NPGetUniversalName(
    LPCWSTR lpLocalPath,
    UNC_INFO_LEVEL dwInfoLevel,
    void* lpBuffer,
    DWORD* lpBufferSize
);

パラメーター

名前方向
lpLocalPathLPCWSTRin
dwInfoLevelUNC_INFO_LEVELin
lpBuffervoid*out
lpBufferSizeDWORD*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD NPGetUniversalName(
    LPCWSTR lpLocalPath,
    UNC_INFO_LEVEL dwInfoLevel,
    void* lpBuffer,
    DWORD* lpBufferSize
);
[DllImport("davclnt.dll", ExactSpelling = true)]
static extern uint NPGetUniversalName(
    [MarshalAs(UnmanagedType.LPWStr)] string lpLocalPath,   // LPCWSTR
    uint dwInfoLevel,   // UNC_INFO_LEVEL
    IntPtr lpBuffer,   // void* out
    ref uint lpBufferSize   // DWORD* in/out
);
<DllImport("davclnt.dll", ExactSpelling:=True)>
Public Shared Function NPGetUniversalName(
    <MarshalAs(UnmanagedType.LPWStr)> lpLocalPath As String,   ' LPCWSTR
    dwInfoLevel As UInteger,   ' UNC_INFO_LEVEL
    lpBuffer As IntPtr,   ' void* out
    ByRef lpBufferSize As UInteger   ' DWORD* in/out
) As UInteger
End Function
' lpLocalPath : LPCWSTR
' dwInfoLevel : UNC_INFO_LEVEL
' lpBuffer : void* out
' lpBufferSize : DWORD* in/out
Declare PtrSafe Function NPGetUniversalName Lib "davclnt" ( _
    ByVal lpLocalPath As LongPtr, _
    ByVal dwInfoLevel As Long, _
    ByVal lpBuffer As LongPtr, _
    ByRef lpBufferSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NPGetUniversalName = ctypes.windll.davclnt.NPGetUniversalName
NPGetUniversalName.restype = wintypes.DWORD
NPGetUniversalName.argtypes = [
    wintypes.LPCWSTR,  # lpLocalPath : LPCWSTR
    wintypes.DWORD,  # dwInfoLevel : UNC_INFO_LEVEL
    ctypes.POINTER(None),  # lpBuffer : void* out
    ctypes.POINTER(wintypes.DWORD),  # lpBufferSize : DWORD* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	davclnt = windows.NewLazySystemDLL("davclnt.dll")
	procNPGetUniversalName = davclnt.NewProc("NPGetUniversalName")
)

// lpLocalPath (LPCWSTR), dwInfoLevel (UNC_INFO_LEVEL), lpBuffer (void* out), lpBufferSize (DWORD* in/out)
r1, _, err := procNPGetUniversalName.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpLocalPath))),
	uintptr(dwInfoLevel),
	uintptr(lpBuffer),
	uintptr(lpBufferSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function NPGetUniversalName(
  lpLocalPath: PWideChar;   // LPCWSTR
  dwInfoLevel: DWORD;   // UNC_INFO_LEVEL
  lpBuffer: Pointer;   // void* out
  lpBufferSize: Pointer   // DWORD* in/out
): DWORD; stdcall;
  external 'davclnt.dll' name 'NPGetUniversalName';
result := DllCall("davclnt\NPGetUniversalName"
    , "WStr", lpLocalPath   ; LPCWSTR
    , "UInt", dwInfoLevel   ; UNC_INFO_LEVEL
    , "Ptr", lpBuffer   ; void* out
    , "Ptr", lpBufferSize   ; DWORD* in/out
    , "UInt")   ; return: DWORD
●NPGetUniversalName(lpLocalPath, dwInfoLevel, lpBuffer, lpBufferSize) = DLL("davclnt.dll", "dword NPGetUniversalName(char*, dword, void*, void*)")
# 呼び出し: NPGetUniversalName(lpLocalPath, dwInfoLevel, lpBuffer, lpBufferSize)
# lpLocalPath : LPCWSTR -> "char*"
# dwInfoLevel : UNC_INFO_LEVEL -> "dword"
# lpBuffer : void* out -> "void*"
# lpBufferSize : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。