Getlogicaldrives, getlogicaldrivestrings, getdrivetype

Source: Internet
Author: User
Tags bitset

 # Include "stdafx. H "<br/> # include <tchar. h> <br/> # include <windows. h> <br/> # include <bitset> <br/> # include <iostream> <br/> # ifdef _ Unicode <br/> # define tcoutwcout <br/> # else <br/> # define tcoutcout <br/> # endif <br/> int _ tmain (INT argc, _ tchar * argv []) <br/>{< br/> tchar tables [] [4] ={< br/> _ T ("://"), <br/> _ T ("B: //"), <br/> _ T ("C: //"), <br/> _ T ("D: // "), <br/> _ T (" E: // "), <br/> _ T (" F ://"), <br/> _ T ("G ://" ), <Br/> _ T ("H: //") <br/>}; </P> <p> STD: bitset <32> Bitmap (:: getlogicaldrives (); <br/> for (size_t I = 0; I <bitmap. size () & I <sizeof (tables)/4; I ++) <br/>{< br/> If (Bitmap [I]) <br/>{< br/> STD: tcout <tables [I] <STD: Endl; <br/>}< br/> STD: cout <_ T ("--------------------------------------------") <STD: Endl; <br/> tchar pszbuffer [max_path]; <br/> DWORD ncnt =: getlogicaldrivestring S (max_path, pszbuffer); <br/> tchar * P; <br/> If (ncnt> 0) <br/>{< br/> P = pszbuffer; <br/> while (* P! = _ T ('/0') <br/>{< br/> STD: tcout <p <STD: Endl; <br/> P = P + _ tcslen (p) + 1; <br/>}</P> <p>/* tchar szbuffer [max_path]; <br/> handle =: findfirstvolume (szbuffer, max_path); <br/> If (handle! = NULL) <br/>{< br/> do {<br/> STD: tcout <szbuffer <STD: Endl; <br/>}while (:: findnextvolume (handle, szbuffer, max_path); <br/>:: findvolumeclose (handle); <br/>}*/<br/> for (size_t I = 0; I <sizeof (tables)/4; I ++) <br/> {<br/> uint nret =: getdrivetype (tables [I]); <br/> // # define drive_unknown 0 <br/> // # define drive_no_root_dir 1 <br/> // # define drive_removable 2 <br/> // # define drive_fixed 3 <br/> // # define drive_remote 4 <br/> // # define drive_cdrom 5 <br/> // # define drive_ramdisk 6 <br/> switch (nret) <br/>{< br/> case drive_unknown: <br/> STD: tcout <tables [I] <_ T ("drive_unknown") <STD :: endl; <br/> break; <br/> case drive_no_root_dir: <br/> STD: tcout <tables [I] <_ T ("drive_no_root_dir ") <STD: Endl; <br/> break; <br/> case drive_removable: <br/> STD :: tcout <tables [I] <_ T ("drive_removable") <STD: Endl; <br/> break; <br/> case drive_fixed: <br/> STD: tcout <tables [I] <_ T ("drive_fixed") <STD: Endl; <br/> break; <br/> case drive_remote: <br/> STD: tcout <tables [I] <_ T ("drive_remote") <STD: Endl; <br/> break; <br/> case drive_cdrom: <br/> STD: tcout <tables [I] <_ T ("drive_cdrom") <STD:: Endl; <br/> break; <br/> case drive_ramdisk: <br/> STD: tcout <tables [I] <_ T ("drive_ramdisk ") <STD: Endl; <br/> break; <br/>}</P> <p> return 0; <br/>}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.