Created
March 18, 2025 21:15
-
-
Save jborean93/6fdc85a519f3b7f8d428203804f85566 to your computer and use it in GitHub Desktop.
Ctypes call to GetDiskFreeSpaceExW
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$k32 = New-CtypesLib Kernel32.dll | |
$free = $total = $totalFree = [int64]0 | |
$res = $k32.SetLastError().GetDiskFreeSpaceExW( | |
$k32.MarshalAs('C:\', 'LPWStr'), | |
[ref]$free, | |
[ref]$total, | |
[ref]$totalFree) | |
if (-not $res) { | |
throw [System.ComponentModel.Win32Exception]::new($k32.LastError) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment