windows 获取已插入U盘

static int GetUdisk(vector <CString> &udisk)
{
    CHAR szDriveStrings[1024];
    PCHAR szDriver;

    memset(szDriveStrings, 0, sizeof(szDriveStrings));
    GetLogicalDriveStrings(sizeof(szDriveStrings), szDriveStrings);

    szDriver = szDriveStrings;
    while (szDriver[0] != '\0') {
        if (GetDriveType(szDriver) == DRIVE_REMOVABLE) {
            udisk.push_back(CString(szDriver));
        }
        szDriver += strlen(szDriver) + 1;
    }

    return 0;
}

posted on 2014-07-25 16:50  JonnyLulu  阅读(329)  评论(0编辑  收藏  举报

导航