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

FindNextVolumeMountPointA

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

シグネチャ

// KERNEL32.dll  (ANSI / -A)
#include <windows.h>

BOOL FindNextVolumeMountPointA(
    HANDLE hFindVolumeMountPoint,
    LPSTR lpszVolumeMountPoint,
    DWORD cchBufferLength
);

パラメーター

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

戻り値の型: BOOL

公式ドキュメント

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

戻り値

関数が成功した場合、戻り値は 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  (ANSI / -A)
#include <windows.h>

BOOL FindNextVolumeMountPointA(
    HANDLE hFindVolumeMountPoint,
    LPSTR lpszVolumeMountPoint,
    DWORD cchBufferLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool FindNextVolumeMountPointA(
    IntPtr hFindVolumeMountPoint,   // HANDLE
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszVolumeMountPoint,   // LPSTR out
    uint cchBufferLength   // DWORD
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function FindNextVolumeMountPointA(
    hFindVolumeMountPoint As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPStr)> lpszVolumeMountPoint As System.Text.StringBuilder,   ' LPSTR out
    cchBufferLength As UInteger   ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hFindVolumeMountPoint : HANDLE
' lpszVolumeMountPoint : LPSTR out
' cchBufferLength : DWORD
Declare PtrSafe Function FindNextVolumeMountPointA Lib "kernel32" ( _
    ByVal hFindVolumeMountPoint As LongPtr, _
    ByVal lpszVolumeMountPoint As String, _
    ByVal cchBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

FindNextVolumeMountPointA = ctypes.windll.kernel32.FindNextVolumeMountPointA
FindNextVolumeMountPointA.restype = wintypes.BOOL
FindNextVolumeMountPointA.argtypes = [
    wintypes.HANDLE,  # hFindVolumeMountPoint : HANDLE
    wintypes.LPSTR,  # lpszVolumeMountPoint : LPSTR 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')
FindNextVolumeMountPointA = Fiddle::Function.new(
  lib['FindNextVolumeMountPointA'],
  [
    Fiddle::TYPE_VOIDP,  # hFindVolumeMountPoint : HANDLE
    Fiddle::TYPE_VOIDP,  # lpszVolumeMountPoint : LPSTR out
    -Fiddle::TYPE_INT,  # cchBufferLength : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn FindNextVolumeMountPointA(
        hFindVolumeMountPoint: *mut core::ffi::c_void,  // HANDLE
        lpszVolumeMountPoint: *mut u8,  // LPSTR 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.Ansi, SetLastError = true)]
public static extern bool FindNextVolumeMountPointA(IntPtr hFindVolumeMountPoint, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder lpszVolumeMountPoint, uint cchBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_FindNextVolumeMountPointA' -Namespace Win32 -PassThru
# $api::FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
#uselib "KERNEL32.dll"
#func global FindNextVolumeMountPointA "FindNextVolumeMountPointA" sptr, sptr, sptr
; FindNextVolumeMountPointA hFindVolumeMountPoint, varptr(lpszVolumeMountPoint), cchBufferLength   ; 戻り値は stat
; hFindVolumeMountPoint : HANDLE -> "sptr"
; lpszVolumeMountPoint : LPSTR out -> "sptr"
; cchBufferLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global FindNextVolumeMountPointA "FindNextVolumeMountPointA" sptr, var, int
; res = FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
; hFindVolumeMountPoint : HANDLE -> "sptr"
; lpszVolumeMountPoint : LPSTR out -> "var"
; cchBufferLength : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL FindNextVolumeMountPointA(HANDLE hFindVolumeMountPoint, LPSTR lpszVolumeMountPoint, DWORD cchBufferLength)
#uselib "KERNEL32.dll"
#cfunc global FindNextVolumeMountPointA "FindNextVolumeMountPointA" intptr, var, int
; res = FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
; hFindVolumeMountPoint : HANDLE -> "intptr"
; lpszVolumeMountPoint : LPSTR out -> "var"
; cchBufferLength : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFindNextVolumeMountPointA = kernel32.NewProc("FindNextVolumeMountPointA")
)

// hFindVolumeMountPoint (HANDLE), lpszVolumeMountPoint (LPSTR out), cchBufferLength (DWORD)
r1, _, err := procFindNextVolumeMountPointA.Call(
	uintptr(hFindVolumeMountPoint),
	uintptr(lpszVolumeMountPoint),
	uintptr(cchBufferLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function FindNextVolumeMountPointA(
  hFindVolumeMountPoint: THandle;   // HANDLE
  lpszVolumeMountPoint: PAnsiChar;   // LPSTR out
  cchBufferLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'FindNextVolumeMountPointA';
result := DllCall("KERNEL32\FindNextVolumeMountPointA"
    , "Ptr", hFindVolumeMountPoint   ; HANDLE
    , "Ptr", lpszVolumeMountPoint   ; LPSTR out
    , "UInt", cchBufferLength   ; DWORD
    , "Int")   ; return: BOOL
●FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength) = DLL("KERNEL32.dll", "bool FindNextVolumeMountPointA(void*, char*, dword)")
# 呼び出し: FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
# hFindVolumeMountPoint : HANDLE -> "void*"
# lpszVolumeMountPoint : LPSTR out -> "char*"
# cchBufferLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "kernel32" fn FindNextVolumeMountPointA(
    hFindVolumeMountPoint: ?*anyopaque, // HANDLE
    lpszVolumeMountPoint: [*c]u8, // LPSTR out
    cchBufferLength: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc FindNextVolumeMountPointA(
    hFindVolumeMountPoint: pointer,  # HANDLE
    lpszVolumeMountPoint: ptr char,  # LPSTR out
    cchBufferLength: uint32  # DWORD
): int32 {.importc: "FindNextVolumeMountPointA", stdcall, dynlib: "KERNEL32.dll".}
pragma(lib, "kernel32");
extern(Windows)
int FindNextVolumeMountPointA(
    void* hFindVolumeMountPoint,   // HANDLE
    char* lpszVolumeMountPoint,   // LPSTR out
    uint cchBufferLength   // DWORD
);
ccall((:FindNextVolumeMountPointA, "KERNEL32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{UInt8}, UInt32),
      hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
# hFindVolumeMountPoint : HANDLE -> Ptr{Cvoid}
# lpszVolumeMountPoint : LPSTR out -> Ptr{UInt8}
# cchBufferLength : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t FindNextVolumeMountPointA(
    void* hFindVolumeMountPoint,
    char* lpszVolumeMountPoint,
    uint32_t cchBufferLength);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
-- hFindVolumeMountPoint : HANDLE
-- lpszVolumeMountPoint : LPSTR out
-- cchBufferLength : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const FindNextVolumeMountPointA = lib.func('__stdcall', 'FindNextVolumeMountPointA', 'int32_t', ['void *', 'char *', 'uint32_t']);
// FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
// hFindVolumeMountPoint : HANDLE -> 'void *'
// lpszVolumeMountPoint : LPSTR out -> 'char *'
// cchBufferLength : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("KERNEL32.dll", {
  FindNextVolumeMountPointA: { parameters: ["pointer", "buffer", "u32"], result: "i32" },
});
// lib.symbols.FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength)
// hFindVolumeMountPoint : HANDLE -> "pointer"
// lpszVolumeMountPoint : LPSTR out -> "buffer"
// cchBufferLength : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t FindNextVolumeMountPointA(
    void* hFindVolumeMountPoint,
    char* lpszVolumeMountPoint,
    uint32_t cchBufferLength);
C, "KERNEL32.dll");
// $ffi->FindNextVolumeMountPointA(hFindVolumeMountPoint, lpszVolumeMountPoint, cchBufferLength);
// hFindVolumeMountPoint : HANDLE
// lpszVolumeMountPoint : LPSTR 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.ASCII_OPTIONS);
    boolean FindNextVolumeMountPointA(
        Pointer hFindVolumeMountPoint,   // HANDLE
        byte[] lpszVolumeMountPoint,   // LPSTR out
        int cchBufferLength   // DWORD
    );
}
@[Link("kernel32")]
lib LibKERNEL32
  fun FindNextVolumeMountPointA = FindNextVolumeMountPointA(
    hFindVolumeMountPoint : Void*,   # HANDLE
    lpszVolumeMountPoint : UInt8*,   # LPSTR 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 FindNextVolumeMountPointANative = Int32 Function(Pointer<Void>, Pointer<Utf8>, Uint32);
typedef FindNextVolumeMountPointADart = int Function(Pointer<Void>, Pointer<Utf8>, int);
final FindNextVolumeMountPointA = DynamicLibrary.open('KERNEL32.dll')
    .lookupFunction<FindNextVolumeMountPointANative, FindNextVolumeMountPointADart>('FindNextVolumeMountPointA');
// hFindVolumeMountPoint : HANDLE -> Pointer<Void>
// lpszVolumeMountPoint : LPSTR out -> Pointer<Utf8>
// cchBufferLength : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function FindNextVolumeMountPointA(
  hFindVolumeMountPoint: THandle;   // HANDLE
  lpszVolumeMountPoint: PAnsiChar;   // LPSTR out
  cchBufferLength: DWORD   // DWORD
): BOOL; stdcall;
  external 'KERNEL32.dll' name 'FindNextVolumeMountPointA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let findnextvolumemountpointa =
  foreign "FindNextVolumeMountPointA"
    ((ptr void) @-> string @-> uint32_t @-> returning int32_t)
(* hFindVolumeMountPoint : HANDLE -> (ptr void) *)
(* lpszVolumeMountPoint : LPSTR out -> string *)
(* 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 ("FindNextVolumeMountPointA" find-next-volume-mount-point-a :convention :stdcall) :int32
  (h-find-volume-mount-point :pointer)   ; HANDLE
  (lpsz-volume-mount-point :pointer)   ; LPSTR out
  (cch-buffer-length :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $FindNextVolumeMountPointA = Win32::API::More->new('KERNEL32',
    'BOOL FindNextVolumeMountPointA(HANDLE hFindVolumeMountPoint, LPSTR lpszVolumeMountPoint, DWORD cchBufferLength)');
# my $ret = $FindNextVolumeMountPointA->Call($hFindVolumeMountPoint, $lpszVolumeMountPoint, $cchBufferLength);
# hFindVolumeMountPoint : HANDLE -> HANDLE
# lpszVolumeMountPoint : LPSTR out -> LPSTR
# cchBufferLength : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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