Win32 API 日本語リファレンス
ホームStorage.FileSystem › FindNextVolumeMountPointW

FindNextVolumeMountPointW

関数
マウントポイント列挙で次の項目を取得する(Unicode版)。
DLLKERNEL32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

BOOL FindNextVolumeMountPointW(
    HANDLE hFindVolumeMountPoint,
    LPWSTR lpszVolumeMountPoint,
    DWORD cchBufferLength
);

パラメーター

名前方向説明
hFindVolumeMountPointHANDLEin前回の FindFirstVolumeMountPoint 関数の呼び出しによって返された、マウントされたフォルダーの検索ハンドル。
lpszVolumeMountPointLPWSTRout見つかった、マウントされたフォルダーの名前を受け取るバッファーへのポインター。
cchBufferLengthDWORDinマウントされたフォルダー名を受け取るバッファーの長さ( TCHAR 単位)。

戻り値の型: BOOL

公式ドキュメント

FindFirstVolumeMountPoint 関数の呼び出しによって開始されたマウントされたフォルダーの検索を続行します。(Unicode)

戻り値

関数が成功した場合、戻り値は 0 以外の値です。

関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、 GetLastError を呼び出します。マウントされたフォルダーがこれ以上見つからない場合、 GetLastError 関数は ERROR_NO_MORE_FILES エラーコードを返します。その場合は、 FindVolumeMountPointClose 関数で検索を終了します。

解説(Remarks)

FindFirstVolumeMountPoint を呼び出して検索ハンドルを確立した後、 FindNextVolumeMountPoint 関数を使用して 他のマウントされたフォルダーを 検索できます。

FindFirstVolumeMountPointFindNextVolumeMountPoint、および FindVolumeMountPointClose 関数は、 指定されたボリュームの、マウントされたフォルダーへのパスを返します。これらはドライブ文字やボリューム GUID パスは返しません。ボリュームのボリューム GUID パスの列挙については、 Enumerating Volume GUID Paths を参照してください。

これらの関数によって返される、マウントされたフォルダーの順序と、他の関数やツールによって返される、マウントされたフォルダーの順序との間に、 何らかの相関関係があると想定すべきではありません。

Windows 8 および Windows Server 2012 において、この関数は次のテクノロジーでサポートされています。

テクノロジー サポート
Server Message Block (SMB) 3.0 プロトコル いいえ
SMB 3.0 Transparent Failover (TFO) いいえ
SMB 3.0 with Scale-out File Shares (SO) いいえ
Cluster Shared Volume File System (CsvFS) いいえ
Resilient File System (ReFS) いいえ

SMB はボリューム管理関数をサポートしていません。CsvFS は CSV ボリューム上でのマウントポイントの追加をサポートしていません。 ReFS はマウントポイントをインデックス化しません。

メモ

winbase.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして FindNextVolumeMountPoint を定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じ、コンパイルエラーまたは実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

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

各言語での呼び出し定義

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

BOOL FindNextVolumeMountPointW(
    HANDLE hFindVolumeMountPoint,
    LPWSTR lpszVolumeMountPoint,
    DWORD cchBufferLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool FindNextVolumeMountPointW(
    IntPtr hFindVolumeMountPoint,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszVolumeMountPoint,   // LPWSTR out
    uint cchBufferLength   // DWORD
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindNextVolumeMountPointW(
    hFindVolumeMountPoint As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> lpszVolumeMountPoint As System.Text.StringBuilder,   ' LPWSTR out
    cchBufferLength As UInteger   ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hFindVolumeMountPoint : HANDLE
' lpszVolumeMountPoint : LPWSTR out
' cchBufferLength : DWORD
Declare PtrSafe Function FindNextVolumeMountPointW Lib "kernel32" ( _
    ByVal hFindVolumeMountPoint As LongPtr, _
    ByVal lpszVolumeMountPoint As LongPtr, _
    ByVal cchBufferLength As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FindNextVolumeMountPointW = ctypes.windll.kernel32.FindNextVolumeMountPointW
FindNextVolumeMountPointW.restype = wintypes.BOOL
FindNextVolumeMountPointW.argtypes = [
    wintypes.HANDLE,  # hFindVolumeMountPoint : HANDLE
    wintypes.LPWSTR,  # lpszVolumeMountPoint : LPWSTR out
    wintypes.DWORD,  # cchBufferLength : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
FindNextVolumeMountPointW = Fiddle::Function.new(
  lib['FindNextVolumeMountPointW'],
  [
    Fiddle::TYPE_VOIDP,  # hFindVolumeMountPoint : HANDLE
    Fiddle::TYPE_VOIDP,  # lpszVolumeMountPoint : LPWSTR out
    -Fiddle::TYPE_INT,  # cchBufferLength : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "kernel32")]
extern "system" {
    fn FindNextVolumeMountPointW(
        hFindVolumeMountPoint: *mut core::ffi::c_void,  // HANDLE
        lpszVolumeMountPoint: *mut u16,  // LPWSTR out
        cchBufferLength: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool FindNextVolumeMountPointW(IntPtr hFindVolumeMountPoint, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszVolumeMountPoint, uint cchBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FindNextVolumeMountPointW' -Namespace Win32 -PassThru
# $api::FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
#uselib "KERNEL32.dll"
#func global FindNextVolumeMountPointW "FindNextVolumeMountPointW" wptr, wptr, wptr
; FindNextVolumeMountPointW hFindVolumeMountPoint, varptr(lpszVolumeMountPoint), cchBufferLength   ; 戻り値は stat
; hFindVolumeMountPoint : HANDLE -> "wptr"
; lpszVolumeMountPoint : LPWSTR out -> "wptr"
; cchBufferLength : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global FindNextVolumeMountPointW "FindNextVolumeMountPointW" sptr, var, int
; res = FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
; hFindVolumeMountPoint : HANDLE -> "sptr"
; lpszVolumeMountPoint : LPWSTR out -> "var"
; cchBufferLength : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL FindNextVolumeMountPointW(HANDLE hFindVolumeMountPoint, LPWSTR lpszVolumeMountPoint, DWORD cchBufferLength)
#uselib "KERNEL32.dll"
#cfunc global FindNextVolumeMountPointW "FindNextVolumeMountPointW" intptr, var, int
; res = FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
; hFindVolumeMountPoint : HANDLE -> "intptr"
; lpszVolumeMountPoint : LPWSTR out -> "var"
; cchBufferLength : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFindNextVolumeMountPointW = kernel32.NewProc("FindNextVolumeMountPointW")
)

// hFindVolumeMountPoint (HANDLE), lpszVolumeMountPoint (LPWSTR out), cchBufferLength (DWORD)
r1, _, err := procFindNextVolumeMountPointW.Call(
	uintptr(hFindVolumeMountPoint),
	uintptr(lpszVolumeMountPoint),
	uintptr(cchBufferLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function FindNextVolumeMountPointW(
  hFindVolumeMountPoint: THandle;   // HANDLE
  lpszVolumeMountPoint: PWideChar;   // LPWSTR out
  cchBufferLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'FindNextVolumeMountPointW';
result := DllCall("KERNEL32\FindNextVolumeMountPointW"
    , "Ptr", hFindVolumeMountPoint   ; HANDLE
    , "Ptr", lpszVolumeMountPoint   ; LPWSTR out
    , "UInt", cchBufferLength   ; DWORD
    , "Int")   ; return: BOOL
●FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength) = DLL("KERNEL32.dll", "bool FindNextVolumeMountPointW(void*, char*, dword)")
# 呼び出し: FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
# hFindVolumeMountPoint : HANDLE -> "void*"
# lpszVolumeMountPoint : LPWSTR out -> "char*"
# cchBufferLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "kernel32" fn FindNextVolumeMountPointW(
    hFindVolumeMountPoint: ?*anyopaque, // HANDLE
    lpszVolumeMountPoint: [*c]u16, // LPWSTR out
    cchBufferLength: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc FindNextVolumeMountPointW(
    hFindVolumeMountPoint: pointer,  # HANDLE
    lpszVolumeMountPoint: ptr uint16,  # LPWSTR out
    cchBufferLength: uint32  # DWORD
): int32 {.importc: "FindNextVolumeMountPointW", stdcall, dynlib: "KERNEL32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "kernel32");
extern(Windows)
int FindNextVolumeMountPointW(
    void* hFindVolumeMountPoint,   // HANDLE
    wchar* lpszVolumeMountPoint,   // LPWSTR out
    uint cchBufferLength   // DWORD
);
ccall((:FindNextVolumeMountPointW, "KERNEL32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{UInt16}, UInt32),
      hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
# hFindVolumeMountPoint : HANDLE -> Ptr{Cvoid}
# lpszVolumeMountPoint : LPWSTR out -> Ptr{UInt16}
# cchBufferLength : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t FindNextVolumeMountPointW(
    void* hFindVolumeMountPoint,
    uint16_t* lpszVolumeMountPoint,
    uint32_t cchBufferLength);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
-- hFindVolumeMountPoint : HANDLE
-- lpszVolumeMountPoint : LPWSTR out
-- cchBufferLength : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const FindNextVolumeMountPointW = lib.func('__stdcall', 'FindNextVolumeMountPointW', 'int32_t', ['void *', 'uint16_t *', 'uint32_t']);
// FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
// hFindVolumeMountPoint : HANDLE -> 'void *'
// lpszVolumeMountPoint : LPWSTR out -> 'uint16_t *'
// cchBufferLength : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  FindNextVolumeMountPointW: { parameters: ["pointer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
// hFindVolumeMountPoint : HANDLE -> "pointer"
// lpszVolumeMountPoint : LPWSTR out -> "buffer"
// cchBufferLength : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t FindNextVolumeMountPointW(
    void* hFindVolumeMountPoint,
    uint16_t* lpszVolumeMountPoint,
    uint32_t cchBufferLength);
C, "KERNEL32.dll");
// $ffi->FindNextVolumeMountPointW(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength);
// hFindVolumeMountPoint : HANDLE
// lpszVolumeMountPoint : LPWSTR out
// cchBufferLength : DWORD
// 構造体/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 Kernel32 extends StdCallLibrary {
    Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
    boolean FindNextVolumeMountPointW(
        Pointer hFindVolumeMountPoint,   // HANDLE
        char[] lpszVolumeMountPoint,   // LPWSTR out
        int cchBufferLength   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("kernel32")]
lib LibKERNEL32
  fun FindNextVolumeMountPointW = FindNextVolumeMountPointW(
    hFindVolumeMountPoint : Void*,   # HANDLE
    lpszVolumeMountPoint : UInt16*,   # LPWSTR out
    cchBufferLength : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef FindNextVolumeMountPointWNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Uint32);
typedef FindNextVolumeMountPointWDart = int Function(Pointer<Void>, Pointer<Utf16>, int);
final FindNextVolumeMountPointW = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<FindNextVolumeMountPointWNative, FindNextVolumeMountPointWDart>('FindNextVolumeMountPointW');
// hFindVolumeMountPoint : HANDLE -> Pointer<Void>
// lpszVolumeMountPoint : LPWSTR out -> Pointer<Utf16>
// cchBufferLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function FindNextVolumeMountPointW(
  hFindVolumeMountPoint: THandle;   // HANDLE
  lpszVolumeMountPoint: PWideChar;   // LPWSTR out
  cchBufferLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'FindNextVolumeMountPointW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "FindNextVolumeMountPointW"
  c_FindNextVolumeMountPointW :: Ptr () -> CWString -> Word32 -> IO CInt
-- hFindVolumeMountPoint : HANDLE -> Ptr ()
-- lpszVolumeMountPoint : LPWSTR out -> CWString
-- cchBufferLength : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let findnextvolumemountpointw =
  foreign "FindNextVolumeMountPointW"
    ((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hFindVolumeMountPoint : HANDLE -> (ptr void) *)
(* lpszVolumeMountPoint : LPWSTR out -> (ptr uint16_t) *)
(* cchBufferLength : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)

(cffi:defcfun ("FindNextVolumeMountPointW" find-next-volume-mount-point-w :convention :stdcall) :int32
  (h-find-volume-mount-point :pointer)   ; HANDLE
  (lpsz-volume-mount-point :pointer)   ; LPWSTR out
  (cch-buffer-length :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $FindNextVolumeMountPointW = Win32::API::More->new('KERNEL32',
    'BOOL FindNextVolumeMountPointW(HANDLE hFindVolumeMountPoint, LPWSTR lpszVolumeMountPoint, DWORD cchBufferLength)');
# my $ret = $FindNextVolumeMountPointW->Call($hFindVolumeMountPoint, $lpszVolumeMountPoint, $cchBufferLength);
# hFindVolumeMountPoint : HANDLE -> HANDLE
# lpszVolumeMountPoint : LPWSTR out -> LPWSTR
# cchBufferLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
公式の関連項目