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.

40 lines
1.1 KiB

  1. #include <windows.h>
  2. #include <winioctl.h>
  3. #include <ntddsnap.h>
  4. #include <stdio.h>
  5. #include <objbase.h>
  6. void __cdecl
  7. main(
  8. int argc,
  9. char** argv
  10. )
  11. {
  12. WCHAR driveName[10];
  13. HANDLE handle;
  14. BOOL b;
  15. DWORD bytes;
  16. if (argc != 2) {
  17. printf("usage: %s drive:\n", argv[0]);
  18. return;
  19. }
  20. swprintf(driveName, L"\\\\?\\%c:", toupper(argv[1][0]));
  21. handle = CreateFile(driveName, GENERIC_READ | GENERIC_WRITE,
  22. FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
  23. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
  24. INVALID_HANDLE_VALUE);
  25. if (handle == INVALID_HANDLE_VALUE) {
  26. printf("Could not open the given volume %d\n", GetLastError());
  27. return;
  28. }
  29. b = DeviceIoControl(handle, IOCTL_VOLSNAP_DELETE_OLDEST_SNAPSHOT,
  30. NULL, 0, NULL, 0, &bytes, NULL);
  31. if (!b) {
  32. printf("Kill failed with %d\n", GetLastError());
  33. }
  34. }