|
用FindFirstFile和FindNextFile, 就必须要那段判断代码
用FindFirstFlashCard 和FindNextFlashCard 则可以不用
一般搜到的第一个是 storage
BOOL bContinue = TRUE; // If TRUE, continue
// searching
// If FALSE, stop searching.
HANDLE hFlashCard; // Search handle for storage
// cards
WIN32_FIND_DATA *lpwfdFlashCard; // Structure for storing
// card information.
lpwfdFlashCard = (WIN32_FIND_DATA *) LocalAlloc (LPTR, 10 * sizeof (WIN32_FIND_DATA));
if (lpwfdFlashCard != NULL) // Failed allocate memory return;
{
hFlashCard = FindFirstFile(TEXT("\\*"), lpwfdFlashCard);
//hFlashCard = FindFirstFlashCard (lpwfdFlashCard);
}
if (hFlashCard == INVALID_HANDLE_VALUE)
{
LocalFree (lpwfdFlashCard); // Free the memory.
return;
}
while (bContinue)
{
//判断代码
if ((lpwfdFlashCard->dwFileAttributes &
(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_TEMPORARY)) ==
(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_TEMPORARY))
{
csPath = lpwfdFlashCard->cFileName; // This Folder is an mounted device (e.g. flash card)
}
// Search for the next storage card.
bContinue = FindNextFile(hFlashCard, lpwfdFlashCard);
//bContinue = FindNextFlashCard (hFlashCard, lpwfdFlashCard);
}
FindClose (hFlashCard); // Close the search handle.
LocalFree (lpwfdFlashCard); // Free the memory.
|
|