다음을 통해 공유


Accessing Files on Other Storage Media (Windows CE 5.0)

Send Feedback

A Windows CE–based device has other areas to store data besides the object store. You can access a file that is stored in ROM just like any other file: by calling the file API. However, you cannot alter a file that is stored in ROM. Instead, ROM-based files are marked with the FILE_ATTRIBUTE_INROM value, which indicates that they are read-only. Windows CE also uses the FILE_ATTRIBUTE_ROMMODULE value to indicate that a file is designated to be executed in ROM, instead of copied to RAM. You cannot use the CreateFile function to open files that are designated with FILE_ATTRIBUTE_ROMMODULE. Instead, use the LoadLibrary and CreateProcess functions to gain access to the module.

In addition, Windows CE supports PC Cards, such as ATA flash cards, and linear flash cards. These cards can have an installed file system that uses the storage space for files and databases. However, a mounted file system must be used in conjunction with an installed file-system driver, such as FAT. After you install a PC Card, you can copy database objects between the object store and the mounted volume.

Windows CE does not assign a letter label to a storage card in the same manner that a desktop computer assigns a drive letter to a hard disk. Instead, the file driver creates directories in the root directory that represent each partition on each storage card. In Windows CE 2.0 and earlier, these directories were given default names, such as Storage Card or PC Card. In Windows CE 2.10 and later, the FAT file-system driver queries the PC Card driver for a default name. If the PC Card driver does not supply a default name, Windows CE uses Storage Card.

You can also tell the difference between a object store directory and a mounted volume directory by the file attributes. When properly set by the block driver using IOCTL_DISK_DEVICE_INFO, the dwAttributes member of the STOREINFO structure specifies the attributes of a volume. To access this information, use GetStoreInfo. For example, for a removable storage device, the block driver sets dwAttributes to STORE_ATTRIBUTE_REMOVABLE.

The folder name of a mounted volume corresponds to a partition in the store. Thus, to find the folder name, find the szVolumeName member of the PARTINFO structure.

The following code example shows how determine if a particular folder name is a removable device.

int     WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPreviousInstance,     LPWSTR lpCommandLine, int nCommandShow)
{
    STOREINFO si;
    HANDLE hSearchStore, hStore, hSearchPart;
    PARTINFO pi;
   TCHAR FolderName[] = TEXT("MyFolder"); // Name of folder to seek
   BOOL bPartFind;

    DWORD cchDest = MAX_PATH;
   TCHAR szMsg[cchDest]; // String to store the result message

// Walk thru the stores
    si.cbSize = sizeof(STOREINFO);
    hSearchStore = FindFirstStore( &si);    
    if (hSearchStore != INVALID_HANDLE_VALUE) {
        do {
            hStore = OpenStore(si.szDeviceName);
            if (hStore != INVALID_HANDLE_VALUE) {

// Get a pointer to STOREINFO
                 GetStoreInfo( hStore, &si);
                pi.cbSize = sizeof(PARTINFO);

// Get a handle for first partition 
                hSearchPart =  FindFirstPartition( hStore, &pi);
                if (hSearchPart != INVALID_HANDLE_VALUE) {
                    do {            

// Check if folder name matches
                  if(wcscmp (pi.szVolumeName, FolderName) == 0) {
                    if(si.dwAttributes == STORE_ATTRIBUTE_REMOVABLE)
                      {
                        StringCchPrintf(szMsg, cchDest, TEXT("%s is a removable storage device."), pi.szVolumeName);
                        return;
                     }
                     else
                     {
                        StringCchPrintf(szMsg, cchDest, TEXT("%s is not a removable storage device."), pi.szVolumeName);
                        return;
                     }
                  }
// Close everything up
                    } while(FindNextPartition( hSearchPart, &pi));
                    FindClose(hSearchPart);
                }
         }
            CloseHandle( hStore);
        } while(FindNextStore(hSearchStore, &si));
        
        FindClose( hSearchStore);
    }    
    return 1;
}

See Also

File System Operations

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.