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この関数が正常に返ったときに、UNC パスのサーバー部分を受け取る文字列へのポインター。この情報が不要な場合、この値は NULL にできます。

戻り値の型: BOOL

公式ドキュメント

パス文字列が、ドライブ文字に基づくパスではなく、有効な Universal Naming Convention (UNC) パスであるかどうかを判定します。この関数は、パスからサーバー名を抽出できる点で PathIsUNC とは異なります。

戻り値

文字列が有効な UNC パスである場合は TRUE を返します。それ以外の場合は FALSE を返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "api-ms-win-core-path-l1-1-0" fn PathIsUNCEx(
    pszPath: [*c]const u16, // LPCWSTR
    ppszServer: [*c][*c]u16 // LPCWSTR* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc PathIsUNCEx(
    pszPath: WideCString,  # LPCWSTR
    ppszServer: ptr WideCString  # LPCWSTR* optional, out
): int32 {.importc: "PathIsUNCEx", stdcall, dynlib: "api-ms-win-core-path-l1-1-0.dll".}
pragma(lib, "api-ms-win-core-path-l1-1-0");
extern(Windows)
int PathIsUNCEx(
    const(wchar)* pszPath,   // LPCWSTR
    wchar** ppszServer   // LPCWSTR* optional, out
);
ccall((:PathIsUNCEx, "api-ms-win-core-path-l1-1-0.dll"), stdcall, Int32,
      (Cwstring, Ptr{Ptr{UInt16}}),
      pszPath, ppszServer)
# pszPath : LPCWSTR -> Cwstring
# ppszServer : LPCWSTR* optional, out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t PathIsUNCEx(
    const uint16_t* pszPath,
    uint16_t** ppszServer);
]]
local api-ms-win-core-path-l1-1-0 = ffi.load("api-ms-win-core-path-l1-1-0")
-- api-ms-win-core-path-l1-1-0.PathIsUNCEx(pszPath, ppszServer)
-- pszPath : LPCWSTR
-- ppszServer : LPCWSTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('api-ms-win-core-path-l1-1-0.dll');
const PathIsUNCEx = lib.func('__stdcall', 'PathIsUNCEx', 'int32_t', ['str16', 'void *']);
// PathIsUNCEx(pszPath, ppszServer)
// pszPath : LPCWSTR -> 'str16'
// ppszServer : LPCWSTR* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("api-ms-win-core-path-l1-1-0.dll", {
  PathIsUNCEx: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.PathIsUNCEx(pszPath, ppszServer)
// pszPath : LPCWSTR -> "buffer"
// ppszServer : LPCWSTR* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t PathIsUNCEx(
    const uint16_t* pszPath,
    uint16_t** ppszServer);
C, "api-ms-win-core-path-l1-1-0.dll");
// $ffi->PathIsUNCEx(pszPath, ppszServer);
// pszPath : LPCWSTR
// ppszServer : LPCWSTR* optional, out
// 構造体/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 Api-ms-win-core-path-l1-1-0 extends StdCallLibrary {
    Api-ms-win-core-path-l1-1-0 INSTANCE = Native.load("api-ms-win-core-path-l1-1-0", Api-ms-win-core-path-l1-1-0.class);
    boolean PathIsUNCEx(
        WString pszPath,   // LPCWSTR
        PointerByReference ppszServer   // LPCWSTR* optional, out
    );
}
@[Link("api-ms-win-core-path-l1-1-0")]
lib Libapi-ms-win-core-path-l1-1-0
  fun PathIsUNCEx = PathIsUNCEx(
    pszPath : UInt16*,   # LPCWSTR
    ppszServer : UInt16**   # LPCWSTR* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PathIsUNCExNative = Int32 Function(Pointer<Utf16>, Pointer<Pointer<Utf16>>);
typedef PathIsUNCExDart = int Function(Pointer<Utf16>, Pointer<Pointer<Utf16>>);
final PathIsUNCEx = DynamicLibrary.open('api-ms-win-core-path-l1-1-0.dll')
    .lookupFunction<PathIsUNCExNative, PathIsUNCExDart>('PathIsUNCEx');
// pszPath : LPCWSTR -> Pointer<Utf16>
// ppszServer : LPCWSTR* optional, out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PathIsUNCEx(
  pszPath: PWideChar;   // LPCWSTR
  ppszServer: PPWideChar   // LPCWSTR* optional, out
): BOOL; stdcall;
  external 'api-ms-win-core-path-l1-1-0.dll' name 'PathIsUNCEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PathIsUNCEx"
  c_PathIsUNCEx :: CWString -> Ptr CWString -> IO CInt
-- pszPath : LPCWSTR -> CWString
-- ppszServer : LPCWSTR* optional, out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pathisuncex =
  foreign "PathIsUNCEx"
    ((ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* pszPath : LPCWSTR -> (ptr uint16_t) *)
(* ppszServer : LPCWSTR* optional, out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library api-ms-win-core-path-l1-1-0 (t "api-ms-win-core-path-l1-1-0.dll"))
(cffi:use-foreign-library api-ms-win-core-path-l1-1-0)

(cffi:defcfun ("PathIsUNCEx" path-is-uncex :convention :stdcall) :int32
  (psz-path (:string :encoding :utf-16le))   ; LPCWSTR
  (ppsz-server :pointer))   ; LPCWSTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PathIsUNCEx = Win32::API::More->new('api-ms-win-core-path-l1-1-0',
    'BOOL PathIsUNCEx(LPCWSTR pszPath, LPVOID ppszServer)');
# my $ret = $PathIsUNCEx->Call($pszPath, $ppszServer);
# pszPath : LPCWSTR -> LPCWSTR
# ppszServer : LPCWSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API