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

PathCchSkipRoot

関数
パスのルート部分を飛ばした位置のポインタを取得する。
DLLapi-ms-win-core-path-l1-1-0.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT PathCchSkipRoot(
    LPCWSTR pszPath,
    LPCWSTR* ppszRootEnd
);

パラメーター

名前方向説明
pszPathLPCWSTRinパス文字列へのポインター。
ppszRootEndLPCWSTR*outこの関数が正常に終了したときに、ドライブ文字または UNC のサーバー/共有パス要素に続くパス内の最初の文字を指すポインターのアドレス。パスがルートのみで構成されている場合、この値は文字列を終端する null 文字を指します。

戻り値の型: HRESULT

公式ドキュメント

ドライブ文字、または UNC (Universal Naming Convention) のサーバー/共有パス要素に続く、パス内の最初の文字へのポインターを取得します。この関数は、"\"、"\?&quot;、および "\?\UNC&quot; のプレフィックスを持つパスを受け付ける点で PathSkipRoot とは異なります。

戻り値

この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

出典・ライセンス: 上記「公式ドキュメント」の内容は 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>

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

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

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

// pszPath (LPCWSTR), ppszRootEnd (LPCWSTR* out)
r1, _, err := procPathCchSkipRoot.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPath))),
	uintptr(ppszRootEnd),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PathCchSkipRoot(
  pszPath: PWideChar;   // LPCWSTR
  ppszRootEnd: PPWideChar   // LPCWSTR* out
): Integer; stdcall;
  external 'api-ms-win-core-path-l1-1-0.dll' name 'PathCchSkipRoot';
result := DllCall("api-ms-win-core-path-l1-1-0\PathCchSkipRoot"
    , "WStr", pszPath   ; LPCWSTR
    , "Ptr", ppszRootEnd   ; LPCWSTR* out
    , "Int")   ; return: HRESULT
●PathCchSkipRoot(pszPath, ppszRootEnd) = DLL("api-ms-win-core-path-l1-1-0.dll", "int PathCchSkipRoot(char*, void*)")
# 呼び出し: PathCchSkipRoot(pszPath, ppszRootEnd)
# pszPath : LPCWSTR -> "char*"
# ppszRootEnd : LPCWSTR* 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 PathCchSkipRoot(
    pszPath: [*c]const u16, // LPCWSTR
    ppszRootEnd: [*c][*c]u16 // LPCWSTR* out
) callconv(std.os.windows.WINAPI) i32;
proc PathCchSkipRoot(
    pszPath: WideCString,  # LPCWSTR
    ppszRootEnd: ptr WideCString  # LPCWSTR* out
): int32 {.importc: "PathCchSkipRoot", stdcall, dynlib: "api-ms-win-core-path-l1-1-0.dll".}
pragma(lib, "api-ms-win-core-path-l1-1-0");
extern(Windows)
int PathCchSkipRoot(
    const(wchar)* pszPath,   // LPCWSTR
    wchar** ppszRootEnd   // LPCWSTR* out
);
ccall((:PathCchSkipRoot, "api-ms-win-core-path-l1-1-0.dll"), stdcall, Int32,
      (Cwstring, Ptr{Ptr{UInt16}}),
      pszPath, ppszRootEnd)
# pszPath : LPCWSTR -> Cwstring
# ppszRootEnd : LPCWSTR* out -> Ptr{Ptr{UInt16}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t PathCchSkipRoot(
    const uint16_t* pszPath,
    uint16_t** ppszRootEnd);
]]
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.PathCchSkipRoot(pszPath, ppszRootEnd)
-- pszPath : LPCWSTR
-- ppszRootEnd : LPCWSTR* 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 PathCchSkipRoot = lib.func('__stdcall', 'PathCchSkipRoot', 'int32_t', ['str16', 'void *']);
// PathCchSkipRoot(pszPath, ppszRootEnd)
// pszPath : LPCWSTR -> 'str16'
// ppszRootEnd : LPCWSTR* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("api-ms-win-core-path-l1-1-0.dll", {
  PathCchSkipRoot: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.PathCchSkipRoot(pszPath, ppszRootEnd)
// pszPath : LPCWSTR -> "buffer"
// ppszRootEnd : LPCWSTR* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t PathCchSkipRoot(
    const uint16_t* pszPath,
    uint16_t** ppszRootEnd);
C, "api-ms-win-core-path-l1-1-0.dll");
// $ffi->PathCchSkipRoot(pszPath, ppszRootEnd);
// pszPath : LPCWSTR
// ppszRootEnd : LPCWSTR* 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);
    int PathCchSkipRoot(
        WString pszPath,   // LPCWSTR
        PointerByReference ppszRootEnd   // LPCWSTR* out
    );
}
@[Link("api-ms-win-core-path-l1-1-0")]
lib Libapi-ms-win-core-path-l1-1-0
  fun PathCchSkipRoot = PathCchSkipRoot(
    pszPath : UInt16*,   # LPCWSTR
    ppszRootEnd : UInt16**   # LPCWSTR* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

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

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

let pathcchskiproot =
  foreign "PathCchSkipRoot"
    ((ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* pszPath : LPCWSTR -> (ptr uint16_t) *)
(* ppszRootEnd : LPCWSTR* 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 ("PathCchSkipRoot" path-cch-skip-root :convention :stdcall) :int32
  (psz-path (:string :encoding :utf-16le))   ; LPCWSTR
  (ppsz-root-end :pointer))   ; LPCWSTR* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PathCchSkipRoot = Win32::API::More->new('api-ms-win-core-path-l1-1-0',
    'int PathCchSkipRoot(LPCWSTR pszPath, LPVOID ppszRootEnd)');
# my $ret = $PathCchSkipRoot->Call($pszPath, $ppszRootEnd);
# pszPath : LPCWSTR -> LPCWSTR
# ppszRootEnd : LPCWSTR* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。