我对c ++很陌生,希望有人可以填写安装存储卡的空白。我试图在Windows mobile下安装我的存储卡。 OpenStore可能正在工作,因为我没有收到错误,但我仍在尝试找出OpenPartition,MountPartition和GetStoreInfo的语法。如果有人能给我一个例子,那真的会有帮助。
这是我到目前为止所做的:
#include "stdafx.h"
#include <storemgr.h>
#include <stdio.h>
int _tmain( int /*argc*/, _TCHAR* /*argv*/[] )
{
STOREINFO si = { 0 };
si.cbSize = sizeof( STOREINFO );
HANDLE hDsk;
HANDLE Findpart;
BOOL success = FALSE;
DWORD Count = 600;
WCHAR szDisk[] = L"DSK2:";
hDsk = OpenStore(szDisk);
HANDLE hPartition = OpenPartition(hDsk, TEXT("Part00"));
MountPartition(hPartition);
if(hDsk == INVALID_HANDLE_VALUE)
printf("Error opening store");
if (!GetStoreInfo(hDsk, &si))
printf("Error getting info");
if(!DismountStore(hDsk))
printf("Error Dismounting");
if(!FormatStore(hDsk))
printf("Error Formatting");
CloseHandle(hDsk);
}
答案 0 :(得分:0)
这里是一些快速测试项目的摘录。希望,它有所帮助。
HANDLE hStore, hPartSearch, hPart;
STOREINFO StoreInfo;
PARTINFO PartInfo[3];
DWORD error;
BOOL bRes;
hStore = OpenStore(L"DSK1:");
if (hStore == INVALID_HANDLE_VALUE)
return;
memset (&StoreInfo, 0, sizeof (StoreInfo));
StoreInfo.cbSize = sizeof(STOREINFO);
if (!GetStoreInfo(hStore, &StoreInfo))
{
error = GetLastError();
}
// 1st part
PartInfo[0].cbSize = sizeof(PartInfo[0]);
hPartSearch = FindFirstPartition(hStore, &PartInfo[0]);
// 2nd part
PartInfo[1].cbSize = sizeof(PartInfo[1]);
FindNextPartition(hPartSearch,&PartInfo[1]);
// Format and remount boot partition
hPart = OpenPartition(hStore, PartInfo[0].szPartitionName);
bRes = DismountPartition(hPart);
error = GetLastError();
bRes = FormatPartition(hPart);
error = GetLastError();
bRes = MountPartition(hPart);
error = GetLastError();
答案 1 :(得分:0)
谢谢timmf
#include "stdafx.h"
#include <storemgr.h>
#include <stdio.h>
int _tmain( int /*argc*/, _TCHAR* /*argv*/[] )
{
STOREINFO si = { 0 };
si.cbSize = sizeof( STOREINFO );
HANDLE hStore, hPartSearch, hPart;
STOREINFO StoreInfo;
PARTINFO PartInfo[3];
DWORD error;
BOOL bRes;
hStore = OpenStore(L"DSK2:");
if (hStore == INVALID_HANDLE_VALUE)
{
printf("Error opening store");
}
memset (&StoreInfo, 0, sizeof (StoreInfo));
StoreInfo.cbSize = sizeof(STOREINFO);
if (!GetStoreInfo(hStore, &StoreInfo))
{
error = GetLastError();
}
// 1st part
PartInfo[0].cbSize = sizeof(PartInfo[0]);
hPartSearch = FindFirstPartition(hStore, &PartInfo[0]);
// 2nd part
PartInfo[1].cbSize = sizeof(PartInfo[1]);
FindNextPartition(hPartSearch,&PartInfo[1]);
// Format and remount boot partition
hPart = OpenPartition(hStore, PartInfo[0].szPartitionName);
bRes = DismountPartition(hPart);
error = GetLastError();
bRes = FormatPartition(hPart);
error = GetLastError();
bRes = MountPartition(hPart);
error = GetLastError();
}