Win32 API 日本語リファレンス
ホームUI.Shell › PathIsUNCEx

PathIsUNCEx

関数
パスがUNC形式かを判定しサーバー部分を返す。
DLLapi-ms-win-core-path-l1-1-0.dll呼出規約winapi対応OSwindows8.0

シグネチャ

// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>

BOOL PathIsUNCEx(
    LPCWSTR pszPath,
    LPCWSTR* ppszServer   // optional
);

パラメーター

名前方向
pszPathLPCWSTRin
ppszServerLPCWSTR*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

// api-ms-win-core-path-l1-1-0.dll
#include <windows.h>

BOOL PathIsUNCEx(
    LPCWSTR pszPath,
    LPCWSTR* ppszServer   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling = true)]
static extern bool PathIsUNCEx(
    [MarshalAs(UnmanagedType.LPWStr)] string pszPath,   // LPCWSTR
    IntPtr ppszServer   // LPCWSTR* optional, out
);
<DllImport("api-ms-win-core-path-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function PathIsUNCEx(
    <MarshalAs(UnmanagedType.LPWStr)> pszPath As String,   ' LPCWSTR
    ppszServer As IntPtr   ' LPCWSTR* optional, out
) As Boolean
End Function
' pszPath : LPCWSTR
' ppszServer : LPCWSTR* optional, out
Declare PtrSafe Function PathIsUNCEx Lib "api-ms-win-core-path-l1-1-0" ( _
    ByVal pszPath As LongPtr, _
    ByVal ppszServer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PathIsUNCEx = ctypes.windll.LoadLibrary("api-ms-win-core-path-l1-1-0.dll").PathIsUNCEx
PathIsUNCEx.restype = wintypes.BOOL
PathIsUNCEx.argtypes = [
    wintypes.LPCWSTR,  # pszPath : LPCWSTR
    ctypes.c_void_p,  # ppszServer : LPCWSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-path-l1-1-0.dll')
PathIsUNCEx = Fiddle::Function.new(
  lib['PathIsUNCEx'],
  [
    Fiddle::TYPE_VOIDP,  # pszPath : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ppszServer : LPCWSTR* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-path-l1-1-0")]
extern "system" {
    fn PathIsUNCEx(
        pszPath: *const u16,  // LPCWSTR
        ppszServer: *const *const u16  // LPCWSTR* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("api-ms-win-core-path-l1-1-0.dll")]
public static extern bool PathIsUNCEx([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr ppszServer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-path-l1-1-0_PathIsUNCEx' -Namespace Win32 -PassThru
# $api::PathIsUNCEx(pszPath, ppszServer)
#uselib "api-ms-win-core-path-l1-1-0.dll"
#func global PathIsUNCEx "PathIsUNCEx" sptr, sptr
; PathIsUNCEx pszPath, varptr(ppszServer)   ; 戻り値は stat
; pszPath : LPCWSTR -> "sptr"
; ppszServer : LPCWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-core-path-l1-1-0.dll"
#cfunc global PathIsUNCEx "PathIsUNCEx" wstr, var
; res = PathIsUNCEx(pszPath, ppszServer)
; pszPath : LPCWSTR -> "wstr"
; ppszServer : LPCWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL PathIsUNCEx(LPCWSTR pszPath, LPCWSTR* ppszServer)
#uselib "api-ms-win-core-path-l1-1-0.dll"
#cfunc global PathIsUNCEx "PathIsUNCEx" wstr, var
; res = PathIsUNCEx(pszPath, ppszServer)
; pszPath : LPCWSTR -> "wstr"
; ppszServer : LPCWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_path_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-core-path-l1-1-0.dll")
	procPathIsUNCEx = api_ms_win_core_path_l1_1_0.NewProc("PathIsUNCEx")
)

// pszPath (LPCWSTR), ppszServer (LPCWSTR* optional, out)
r1, _, err := procPathIsUNCEx.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
	uintptr(ppszServer),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function PathIsUNCEx(
  pszPath: PWideChar;   // LPCWSTR
  ppszServer: PPWideChar   // LPCWSTR* optional, out
): BOOL; stdcall;
  external 'api-ms-win-core-path-l1-1-0.dll' name 'PathIsUNCEx';
result := DllCall("api-ms-win-core-path-l1-1-0\PathIsUNCEx"
    , "WStr", pszPath   ; LPCWSTR
    , "Ptr", ppszServer   ; LPCWSTR* optional, out
    , "Int")   ; return: BOOL
●PathIsUNCEx(pszPath, ppszServer) = DLL("api-ms-win-core-path-l1-1-0.dll", "bool PathIsUNCEx(char*, void*)")
# 呼び出し: PathIsUNCEx(pszPath, ppszServer)
# pszPath : LPCWSTR -> "char*"
# ppszServer : LPCWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。