CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    Dealing with bitmask

    Within Win32 API the is a function
    getlogicaldrives returns a DWORD , as all logical drives on your system ,

    reference here
    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx ,

    it usage it some what cryptic , as it returns all drives as bit mask ,

    could some explain what bit mask are and how to use them , as in get some meaning full data out of them.

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Dealing with bitmask

    MSDN: Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.

    Code:
    DWORD mask = GetLogicalDrives();
    
    if ( mask & (1 << 0) )
    {
        // drive A is available
    }
    
    if ( mask & (1 << 1) )
    {
        // drive B is available
    }
    
    if ( mask & (1 << 2) )
    {
        // drive C is available
    }
    
    ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured