Winapi: getlogicaldrivestrings-get the logical drive string in the system

Source: Internet
Author: User
// Declaration: getlogicaldrivestrings (nbufferlength: DWORD; {buffer size} lpbuffer: pansichar {buffer}): DWORD; // The buffer result is stored as follows: for example, drive a is represented as a: \ separated by an empty character, followed by backward; // Therefore, each drive occupies 4 bytes.

 // Example: Procedure tform1.formcreate (Sender: tobject); var pstr: pchar; drivearr: array [0 .. 4*26] of char; {4 bytes per drive, up to 26 drives} begin getlogicaldrivestrings (sizeof (drivearr), drivearr); {function call is that simple} pstr: = drivearr; {because pstr ends with #0, it now points to the first 4 bytes} memo1.clear; {clear memo} while pstrnil do begin memo1.lines. add (pstr); Inc (pstr, strlen (pstr) + 1); {the string pointer can be operated, which is equivalent to moving the pointer to four positions, pointing to the next} If (byte (pstr [0]) = 0) Then pstr: = nil; {if the first character of the next row is null, it means no more, while waiting for nil to terminate} end;

 //:


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.