Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include<iostream>
  4. #include <conio.h>
  5.  
  6.  
  7. // You may want to try wmain() version
  8. using namespace std;
  9. int main(void)
  10.  
  11. {
  12.  
  13. // A pointer to a null-terminated string that specifies a directory on a disk.
  14.  
  15. // If this parameter is NULL, the function uses the root of the current disk.
  16.  
  17. // If this parameter is a UNC name, it must include a trailing backslash,
  18.  
  19. // for example, \\MyServer\MyShare\. This parameter does not have to specify the
  20.  
  21. // root directory on a disk. The function accepts any directory on a disk. Here we are using NULL, using the root of the current disk
  22.  
  23.  
  24. setlocale(LC_ALL,"Russian");
  25. cout << "Подключенные дисковые устройства: " << endl;
  26. char buf[26];
  27. GetLogicalDriveStringsA(sizeof(buf),buf);
  28. char *DRF [] = {"Неизвестно" , "Неправильный путь",
  29. "Внешний", "Внутренний" , "Сетевое устройство","CD-ROM", "RAM диск"};
  30. for(char *s=buf; *s; s+=strlen(s)+1)
  31. cout<<s<<" "<<DRF[GetDriveTypeA(s)]<<endl;
  32.  
  33. __int64 lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes;
  34.  
  35. DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters;
  36.  
  37.  
  38.  
  39. // If the function succeeds, the return value is nonzero. If the function fails, the return value is 0 (zero).
  40. LPCSTR pszDrive = NULL;
  41.  
  42. BOOL test, fResult;
  43. test = GetDiskFreeSpaceEx(
  44.  
  45. pszDrive,
  46.  
  47. (PULARGE_INTEGER)&lpFreeBytesAvailable,
  48.  
  49. (PULARGE_INTEGER)&lpTotalNumberOfBytes,
  50.  
  51. (PULARGE_INTEGER)&lpTotalNumberOfFreeBytes
  52.  
  53. );
  54.  
  55.  
  56. printf("Total number of bytes available for user: %ul\n", lpTotalNumberOfBytes);
  57.  
  58. system("pause");
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement