ホーム › Networking.Clustering › ClusterGetVolumePathName
ClusterGetVolumePathName
関数ファイルパスからボリュームのマウントパスを取得する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
BOOL ClusterGetVolumePathName(
LPCWSTR lpszFileName,
LPWSTR lpszVolumePathName,
DWORD cchBufferLength
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszFileName | LPCWSTR | in |
| lpszVolumePathName | LPWSTR | out |
| cchBufferLength | DWORD | in |
戻り値の型: BOOL
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
BOOL ClusterGetVolumePathName(
LPCWSTR lpszFileName,
LPWSTR lpszVolumePathName,
DWORD cchBufferLength
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("RESUTILS.dll", SetLastError = true, ExactSpelling = true)]
static extern bool ClusterGetVolumePathName(
[MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszVolumePathName, // LPWSTR out
uint cchBufferLength // DWORD
);<DllImport("RESUTILS.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ClusterGetVolumePathName(
<MarshalAs(UnmanagedType.LPWStr)> lpszFileName As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszVolumePathName As System.Text.StringBuilder, ' LPWSTR out
cchBufferLength As UInteger ' DWORD
) As Boolean
End Function' lpszFileName : LPCWSTR
' lpszVolumePathName : LPWSTR out
' cchBufferLength : DWORD
Declare PtrSafe Function ClusterGetVolumePathName Lib "resutils" ( _
ByVal lpszFileName As LongPtr, _
ByVal lpszVolumePathName As LongPtr, _
ByVal cchBufferLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ClusterGetVolumePathName = ctypes.windll.resutils.ClusterGetVolumePathName
ClusterGetVolumePathName.restype = wintypes.BOOL
ClusterGetVolumePathName.argtypes = [
wintypes.LPCWSTR, # lpszFileName : LPCWSTR
wintypes.LPWSTR, # lpszVolumePathName : 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('RESUTILS.dll')
ClusterGetVolumePathName = Fiddle::Function.new(
lib['ClusterGetVolumePathName'],
[
Fiddle::TYPE_VOIDP, # lpszFileName : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszVolumePathName : LPWSTR out
-Fiddle::TYPE_INT, # cchBufferLength : DWORD
],
Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ClusterGetVolumePathName(
lpszFileName: *const u16, // LPCWSTR
lpszVolumePathName: *mut u16, // LPWSTR out
cchBufferLength: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("RESUTILS.dll", SetLastError = true)]
public static extern bool ClusterGetVolumePathName([MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszVolumePathName, uint cchBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ClusterGetVolumePathName' -Namespace Win32 -PassThru
# $api::ClusterGetVolumePathName(lpszFileName, lpszVolumePathName, cchBufferLength)#uselib "RESUTILS.dll"
#func global ClusterGetVolumePathName "ClusterGetVolumePathName" sptr, sptr, sptr
; ClusterGetVolumePathName lpszFileName, varptr(lpszVolumePathName), cchBufferLength ; 戻り値は stat
; lpszFileName : LPCWSTR -> "sptr"
; lpszVolumePathName : LPWSTR out -> "sptr"
; cchBufferLength : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RESUTILS.dll" #cfunc global ClusterGetVolumePathName "ClusterGetVolumePathName" wstr, var, int ; res = ClusterGetVolumePathName(lpszFileName, lpszVolumePathName, cchBufferLength) ; lpszFileName : LPCWSTR -> "wstr" ; lpszVolumePathName : LPWSTR out -> "var" ; cchBufferLength : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RESUTILS.dll" #cfunc global ClusterGetVolumePathName "ClusterGetVolumePathName" wstr, sptr, int ; res = ClusterGetVolumePathName(lpszFileName, varptr(lpszVolumePathName), cchBufferLength) ; lpszFileName : LPCWSTR -> "wstr" ; lpszVolumePathName : LPWSTR out -> "sptr" ; cchBufferLength : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL ClusterGetVolumePathName(LPCWSTR lpszFileName, LPWSTR lpszVolumePathName, DWORD cchBufferLength) #uselib "RESUTILS.dll" #cfunc global ClusterGetVolumePathName "ClusterGetVolumePathName" wstr, var, int ; res = ClusterGetVolumePathName(lpszFileName, lpszVolumePathName, cchBufferLength) ; lpszFileName : LPCWSTR -> "wstr" ; lpszVolumePathName : LPWSTR out -> "var" ; cchBufferLength : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL ClusterGetVolumePathName(LPCWSTR lpszFileName, LPWSTR lpszVolumePathName, DWORD cchBufferLength) #uselib "RESUTILS.dll" #cfunc global ClusterGetVolumePathName "ClusterGetVolumePathName" wstr, intptr, int ; res = ClusterGetVolumePathName(lpszFileName, varptr(lpszVolumePathName), cchBufferLength) ; lpszFileName : LPCWSTR -> "wstr" ; lpszVolumePathName : LPWSTR out -> "intptr" ; cchBufferLength : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procClusterGetVolumePathName = resutils.NewProc("ClusterGetVolumePathName")
)
// lpszFileName (LPCWSTR), lpszVolumePathName (LPWSTR out), cchBufferLength (DWORD)
r1, _, err := procClusterGetVolumePathName.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszFileName))),
uintptr(lpszVolumePathName),
uintptr(cchBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ClusterGetVolumePathName(
lpszFileName: PWideChar; // LPCWSTR
lpszVolumePathName: PWideChar; // LPWSTR out
cchBufferLength: DWORD // DWORD
): BOOL; stdcall;
external 'RESUTILS.dll' name 'ClusterGetVolumePathName';result := DllCall("RESUTILS\ClusterGetVolumePathName"
, "WStr", lpszFileName ; LPCWSTR
, "Ptr", lpszVolumePathName ; LPWSTR out
, "UInt", cchBufferLength ; DWORD
, "Int") ; return: BOOL●ClusterGetVolumePathName(lpszFileName, lpszVolumePathName, cchBufferLength) = DLL("RESUTILS.dll", "bool ClusterGetVolumePathName(char*, char*, dword)")
# 呼び出し: ClusterGetVolumePathName(lpszFileName, lpszVolumePathName, cchBufferLength)
# lpszFileName : LPCWSTR -> "char*"
# lpszVolumePathName : LPWSTR out -> "char*"
# cchBufferLength : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。