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

FindFirstVolumeMountPointA

関数
ボリューム上のマウントポイント列挙を開始する(ANSI版)。
DLLKERNEL32.dll文字セットANSI (-A)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

HANDLE FindFirstVolumeMountPointA(
    LPCSTR lpszRootPathName,
    LPSTR lpszVolumeMountPoint,
    DWORD cchBufferLength
);

パラメーター

名前方向
lpszRootPathNameLPCSTRin
lpszVolumeMountPointLPSTRout
cchBufferLengthDWORDin

戻り値の型: HANDLE

各言語での呼び出し定義

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

HANDLE FindFirstVolumeMountPointA(
    LPCSTR lpszRootPathName,
    LPSTR lpszVolumeMountPoint,
    DWORD cchBufferLength
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr FindFirstVolumeMountPointA(
    [MarshalAs(UnmanagedType.LPStr)] string lpszRootPathName,   // LPCSTR
    [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 FindFirstVolumeMountPointA(
    <MarshalAs(UnmanagedType.LPStr)> lpszRootPathName As String,   ' LPCSTR
    <MarshalAs(UnmanagedType.LPStr)> lpszVolumeMountPoint As System.Text.StringBuilder,   ' LPSTR out
    cchBufferLength As UInteger   ' DWORD
) As IntPtr
End Function
' lpszRootPathName : LPCSTR
' lpszVolumeMountPoint : LPSTR out
' cchBufferLength : DWORD
Declare PtrSafe Function FindFirstVolumeMountPointA Lib "kernel32" ( _
    ByVal lpszRootPathName As String, _
    ByVal lpszVolumeMountPoint As String, _
    ByVal cchBufferLength As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procFindFirstVolumeMountPointA = kernel32.NewProc("FindFirstVolumeMountPointA")
)

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