Created
August 25, 2019 12:53
-
-
Save kazuki-ma/9c0457114e3ea0f5e249fe06b3f38471 to your computer and use it in GitHub Desktop.
This file contains 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
var ( | |
modkernel32 = windows.NewLazySystemDLL("kernel32.dll") | |
procCreateServiceW = modkernel32.NewProc("GetDiskFreeSpaceW") | |
) | |
func getClusterSizeOfCurrentDirectory() (int64, error) { | |
var lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters int64 | |
// cstr, _ := syscall.BytePtrFromString("C:") | |
_, _, errNo := syscall.Syscall6(procCreateServiceW.Addr(), | |
6, | |
0, | |
uintptr(unsafe.Pointer(&lpSectorsPerCluster)), | |
uintptr(unsafe.Pointer(&lpBytesPerSector)), | |
uintptr(unsafe.Pointer(&lpNumberOfFreeClusters)), | |
uintptr(unsafe.Pointer(&lpTotalNumberOfClusters)), | |
0) | |
if errNo != 0 { | |
return 0, errNo | |
} | |
return lpSectorsPerCluster * lpBytesPerSector, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment