PPC - List and Locate Storage Card Files

From YYpBD's MediaWiki

Jump to: navigation, search

#include <shlobj.h>
#pragma comment(lib, "ceshell.lib")

TCHAR szPath[MAX_PATH];
if (!SHGetDocumentsFolder(L"\\", szPath))
    MessageBox(NULL, L"Invalid Path", L"Call Failed", MB_OK);
else
    MessageBox(NULL, szPath, L"My Docs Path", MB_OK);








for (index = 0; index < iNumOfFlashCard; ++index)
{
    // Store the directory name in szName.
    wsprintf(szSCName, lpwfdFlashCard[index].cFileName);
    iNumFolders = EnumProjects (EnumProjProc, lpwfdFlashCard[index].dwOID,
                                PRJ_ENUM_FLASH, 0);
}





BOOL CALLBACK EnumProjProc (DWORD dwOID, LPARAM lParam)
{
    // Search handle for files under each directory.
    HANDLE hSearch;    
    // Structure for storing the storage card information
    // retrieved by CeOidGetInfo.
    CEOIDINFO OidInfo;
    // Structure for storing file information.
    WIN32_FIND_DATA fd;
    // String for storing the file or directory
    // name on every storage card.
    TCHAR szName[1000];
    // String for storing the error message.
    TCHAR szErrorMsg[1000];    
    // Wildcard file names with full paths for searching these
    // types of files.
    TCHAR szFilePath[MAX_PATH];
    // Whether the search for files is finished.
    BOOLEAN bFinished = FALSE;

    // Get storage card information by using its object identifier.
    if (!CeOidGetInfo (dwOID, &OidInfo))
    {
        return FALSE; // Stop enumeration.
    }
    // Store the directory name in szName.
    wsprintf(szName, OidInfo.infDirectory.szDirName);
    // Construct the wildcard file name with the full path for searching
    // that type of file.
    wcscpy (szFilePath, OidInfo.infDirectory.szDirName);
    wcscat (szFilePath, TEXT("\\*.*"));
    // Search for the first file under the current directory. An
    // alternative way to do this is to use FindFirstProjectFile.
    hSearch = FindFirstFile( szFilePath, &fd);
    if (hSearch == INVALID_HANDLE_VALUE)
    {
        wsprintf(szErrorMsg, TEXT("No files found."));
        bFinished = TRUE;      
    }
    // Find all of the files and retrieve the file names.
    while (!bFinished)
    {
        // Store the file name in szName.
        wsprintf(szName, fd.cFileName);
        if (!FindNextProjectFile(hSearch, &fd))
        {
        // Finished.
            bFinished = TRUE;
            if (GetLastError() == ERROR_NO_MORE_FILES)
            {
                wsprintf(szErrorMsg, TEXT("Found all of the files."));
            }
            else
            {
                wsprintf(szErrorMsg, TEXT("Couldn't find next file."));
            }
        }
    }
    // Close the search handle.
    if (!FindClose(hSearch))
    {
        wsprintf(szErrorMsg, TEXT("Couldn't close search handle."));
    }
    return TRUE;
}


맞춤검색