0

我对 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);
}
4

2 回答 2

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();
}
于 2013-05-23T12:55:46.473 回答
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();
于 2013-05-23T12:14:35.267 回答