가능한 중복 설치 :
How to list physical disks?목록 물리적 드라이브가 내 컴퓨터에
무엇인가 "가장 좋은 방법"내 컴퓨터에 설치된 실제 드라이브를 나열하기 (빠른) C++ 방법은? 거기에 할 수있는 부스트 라이브러리가 있습니까?
가능한 중복 설치 :
How to list physical disks?목록 물리적 드라이브가 내 컴퓨터에
무엇인가 "가장 좋은 방법"내 컴퓨터에 설치된 실제 드라이브를 나열하기 (빠른) C++ 방법은? 거기에 할 수있는 부스트 라이브러리가 있습니까?
GetLogicalDriveStrings()
을 사용하여 사용 가능한 모든 논리 드라이브를 검색하십시오.
#include <windows.h>
#include <stdio.h>
DWORD mydrives = 100;// buffer length
char lpBuffer[100];// buffer for drive string storage
int main()
{
DWORD test = GetLogicalDriveStrings(mydrives, lpBuffer);
printf("The logical drives of this machine are:\n\n");
for(int i = 0; i<100; i++) printf("%c", lpBuffer[i]);
printf("\n");
return 0;
}
또는 GetLogicalDrives()
#include <windows.h>
#include <direct.h>
#include <stdio.h>
#include <tchar.h>
// initial value
TCHAR szDrive[ ] = _T(" A:");
int main()
{
DWORD uDriveMask = GetLogicalDrives();
printf("The bitmask of the logical drives in hex: %0X\n", uDriveMask);
printf("The bitmask of the logical drives in decimal: %d\n", uDriveMask);
if(uDriveMask == 0)
printf("\nGetLogicalDrives() failed with failure code: %d\n", GetLastError());
else
{
printf("\nThis machine has the following logical drives:\n");
while(uDriveMask)
{// use the bitwise AND, 1–available, 0-not available
if(uDriveMask & 1)
printf("%s\n",szDrive);
// increment...
++szDrive[1];
// shift the bitmask binary right
uDriveMask >>= 1;
}
printf("\n ");
}
return 0;
}
하나의 가능성을 사용 Win32_DiskDrive의 인스턴스를 열거 할 수 WMI를 사용하는 것입니다.
그래서 부스트 만 하시겠습니까? 어떤 라이브러리를 사용할 수 있습니까? 어떤 운영 체제입니까? –
어떤 OS를 사용하고 있습니까? – Cyclonecode
@ Mr.TAMER Windows는 내가하고있는 시스템입니다. 부스트가 선호되는 방법이지만, 부스트가없는 경우에는 받아 들여질 것입니다. – smallB