Closed DDXBIZ closed 6 months ago
Here's a simple example of obtaining the volume name of a drive:
import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:win32/win32.dart';
void main() {
// Specify the root directory of the volume (e.g., 'C:\')
const rootPath = r'C:\';
final lpRootName = rootPath.toNativeUtf16();
final lpVolumeName = wsalloc(MAX_PATH + 1);
if (GetVolumeInformation(lpRootName, lpVolumeName, MAX_PATH + 1, nullptr,
nullptr, nullptr, nullptr, NULL) !=
NULL) {
final volumeName = lpVolumeName.toDartString();
print('$rootPath volume name: $volumeName');
} else {
print('Error getting volume information.');
}
free(lpVolumeName);
free(lpRootName);
}
Thanks. This is a great Help.
How do I get the Volume Name for each Drive using win32 ? is this possible? would you have an example?
I have tried the explorer example app, but I cannot get this volume name...
Please advice.