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.

50 lines
1.3 KiB

  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <ctype.h>
  4. #include <ftapi.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. FT_LOGICAL_DISK_ID newDiskId;
  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 = FtCreatePartitionLogicalDisk(h, &newDiskId);
  34. CloseHandle(h);
  35. if (b) {
  36. printf("Partition created with logical disk id %I64X\n", newDiskId);
  37. } else {
  38. printf("Partition create failed with %d\n", GetLastError());
  39. }
  40. FtSetStickyDriveLetter(newDiskId, (UCHAR) toupper(argv[1][0]));
  41. }