ホーム › Storage.FileSystem › GetDriveTypeA
GetDriveTypeA
関数指定ルートパスのドライブ種別を取得する(ANSI版)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
DWORD GetDriveTypeA(
LPCSTR lpRootPathName // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpRootPathName | LPCSTR | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
DWORD GetDriveTypeA(
LPCSTR lpRootPathName // optional
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern uint GetDriveTypeA(
[MarshalAs(UnmanagedType.LPStr)] string lpRootPathName // LPCSTR optional
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GetDriveTypeA(
<MarshalAs(UnmanagedType.LPStr)> lpRootPathName As String ' LPCSTR optional
) As UInteger
End Function' lpRootPathName : LPCSTR optional
Declare PtrSafe Function GetDriveTypeA Lib "kernel32" ( _
ByVal lpRootPathName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetDriveTypeA = ctypes.windll.kernel32.GetDriveTypeA
GetDriveTypeA.restype = wintypes.DWORD
GetDriveTypeA.argtypes = [
wintypes.LPCSTR, # lpRootPathName : LPCSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetDriveTypeA = Fiddle::Function.new(
lib['GetDriveTypeA'],
[
Fiddle::TYPE_VOIDP, # lpRootPathName : LPCSTR optional
],
-Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn GetDriveTypeA(
lpRootPathName: *const u8 // LPCSTR optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi)]
public static extern uint GetDriveTypeA([MarshalAs(UnmanagedType.LPStr)] string lpRootPathName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetDriveTypeA' -Namespace Win32 -PassThru
# $api::GetDriveTypeA(lpRootPathName)#uselib "KERNEL32.dll"
#func global GetDriveTypeA "GetDriveTypeA" sptr
; GetDriveTypeA lpRootPathName ; 戻り値は stat
; lpRootPathName : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global GetDriveTypeA "GetDriveTypeA" str
; res = GetDriveTypeA(lpRootPathName)
; lpRootPathName : LPCSTR optional -> "str"; DWORD GetDriveTypeA(LPCSTR lpRootPathName)
#uselib "KERNEL32.dll"
#cfunc global GetDriveTypeA "GetDriveTypeA" str
; res = GetDriveTypeA(lpRootPathName)
; lpRootPathName : LPCSTR optional -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetDriveTypeA = kernel32.NewProc("GetDriveTypeA")
)
// lpRootPathName (LPCSTR optional)
r1, _, err := procGetDriveTypeA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpRootPathName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetDriveTypeA(
lpRootPathName: PAnsiChar // LPCSTR optional
): DWORD; stdcall;
external 'KERNEL32.dll' name 'GetDriveTypeA';result := DllCall("KERNEL32\GetDriveTypeA"
, "AStr", lpRootPathName ; LPCSTR optional
, "UInt") ; return: DWORD●GetDriveTypeA(lpRootPathName) = DLL("KERNEL32.dll", "dword GetDriveTypeA(char*)")
# 呼び出し: GetDriveTypeA(lpRootPathName)
# lpRootPathName : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。