windows mobile中求存储空间大小
以下函数可得到主内存信息:
BOOL GetStoreInformation(
LPSTORE_INFORMATION lpsi
);
参数定义:
typedef struct STORE_INFORMATION {
DWORD dwStoreSize;
DWORD dwFreeSize;
} STORE_INFORMATION, *LPSTORE_INFORMATION;
以下函数可得到存储卡的信息:
BOOL GetDiskFreeSpaceEx(
LPCWSTR lpDirectoryName,
PULARGE_INTEGER lpFreeBytesAvailableToCaller,
PULARGE_INTEGER lpTotalNumberOfBytes,
PULARGE_INTEGER lpTotalNumberOfFreeBytes
);
参数定义:
#if defined(MIDL_PASS)
typedef struct _ULARGE_INTEGER {
#else // MIDL_PASS
typedef union _ULARGE_INTEGER {
struct {
DWORD LowPart;
DWORD HighPart;
};
struct {
DWORD LowPart;
DWORD HighPart;
} u;
#endif //MIDL_PASS
ULONGLONG QuadPart;
} ULARGE_INTEGER;
typedef ULARGE_INTEGER *PULARGE_INTEGER;
我们试试调用GetDiskFreeSpaceEx:
ULARGE_INTEGER ulFree;
if(GetDiskFreeSpaceEx(L"Storage Card", NULL, NULL, &ulFree))
{
_int64 iSize = ulFree.QuadPart;
if(iSize < 2*1024*1024)//保留2M空间
{
MessageBox(L"存储卡空间不足,请删除旧的或不使用的项目以创建更多空间。", L"", MB_OK);
}
}