小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

GetLogicalDrives()函數(shù)

 tianht 2015-04-21

原型:DWORD GetLogicalDrivers (void);

說明:函數(shù)返回值是一個long型,將其用二進制顯示時,其中第0位表示A盤,第1位表示B盤,當某位為1時說明存在這個盤,即00000011表示有A盤和B盤。

看這個例子:

#include <windows.h>
int main()
{
DWORD dw;
TCHAR TC1[50],TC2[50];


dw = GetLogicalDrives();
wsprintf(TC1,"%ld",dw);
MessageBox(NULL,TC1,"十進制",MB_OK);


_itoa(dw,TC2,2);
MessageBox(NULL,TC2,"十進制",MB_OK);
return 0;
}

 一目了然哈


改下:

#include <windows.h>
int main()
{
DWORD dw;
TCHAR TC[50];
    int count = 0;
dw = GetLogicalDrives();
while(dw != 0)
{
   if( (dw&1) != 0)
   {
       count++;
   }
   dw >>= 1;
}
wsprintf(TC,"驅(qū)動器個數(shù):%d",count);
MessageBox(NULL,TC,"我插了U盤的",MB_OK);
return 0;
}


判斷某個盤符是否存在:

#include <windows.h>
int main()
{
    DWORD dw;
    TCHAR TC[50];
    dw = GetLogicalDrives();
    char ch;
    ch = 'Q';
    int n = ch - 'A';


    if( (dw != 0) && (dw >>= n) != 0 )
    {
        wsprintf(TC,"%c 盤 存 在",ch);
    }
    else
    {
        wsprintf(TC,"%c 盤 不 存 在",ch);
    }


    MessageBox(NULL,TC,"判斷 該盤 是否存在",MB_OK);
    return 0;
}





MSDN:

GetLogicalDrives

The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives.

DWORD GetLogicalDrives(VOID);

Parameters

This function has no parameters.

Return Values

If the function succeeds, the return value is a bitmask representing the currently available disk drives. 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.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Windows XP: This function returns a concatenation of the logical disks in the Global and Local MS-DOS Device namespaces. If a logical disk exists in both namespaces, this function will return the entry in the Local MS-DOS Devices namespace.

For more information on the Global and Local MS-DOS Device namespaces and changes to the accessibility of MS-DOS device names in Windows XP, refer to MS-DOS Device Names.

Requirements

Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權內(nèi)容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多