Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <winioctl.h>
  4. #include <ntddvol.h>
  5. void __cdecl
  6. main(
  7. int argc,
  8. char** argv
  9. )
  10. {
  11. WCHAR driveName[7];
  12. HANDLE h;
  13. BOOL b;
  14. DWORD bytes;
  15. if (argc != 2) {
  16. printf("usage: %s drive:\n", argv[0]);
  17. return;
  18. }
  19. driveName[0] = '\\';
  20. driveName[1] = '\\';
  21. driveName[2] = '.';
  22. driveName[3] = '\\';
  23. driveName[4] = argv[1][0];
  24. driveName[5] = ':';
  25. driveName[6] = 0;
  26. h = CreateFileW(driveName, GENERIC_READ | GENERIC_WRITE,
  27. FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
  28. NULL, OPEN_EXISTING, 0, INVALID_HANDLE_VALUE);
  29. if (h == INVALID_HANDLE_VALUE) {
  30. printf("Open of drive %c: failed with %d\n", argv[1][0], GetLastError());
  31. return;
  32. }
  33. b = DeviceIoControl(h, IOCTL_VOLUME_ONLINE, NULL, 0, NULL, 0, &bytes,
  34. NULL);
  35. if (b) {
  36. printf("Online succeeded.\n");
  37. } else {
  38. printf("Online failed with %d\n", GetLastError());
  39. }
  40. }