yanh123
驱动牛犊
驱动牛犊
  • 注册日期2007-08-03
  • 最后登录2009-08-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望31点
  • 贡献值0点
  • 好评度20点
  • 原创分0分
  • 专家分0分
阅读:1926回复:5

想做一个SD卡格式化的工具,不知道调用那个函数

楼主#
更多 发布于:2007-11-15 16:24
我想在Wince上做一个格式化的应用程序,不知道调用那个函数,直接给驱动发DeviceIOControl还是调用文件系统的API?微软有没有什么API可以实现对SD卡的格式化?
zhengshijie
驱动小牛
驱动小牛
  • 注册日期2003-07-11
  • 最后登录2009-03-18
  • 粉丝1
  • 关注0
  • 积分8分
  • 威望217点
  • 贡献值0点
  • 好评度199点
  • 原创分3分
  • 专家分0分
沙发#
发布于:2007-11-15 19:01
如果你装有WINCE500,建议你参考WINCE500\public\wceshellfe\oak\ctlpnl\stgui\maindlg.cpp中的代码:
BOOL   WINAPI FormatStore(HANDLE hStore)
{
    return (PSLFormatStore(hStore) == TRUE) ? TRUE : FALSE;
}
yanh123
驱动牛犊
驱动牛犊
  • 注册日期2007-08-03
  • 最后登录2009-08-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望31点
  • 贡献值0点
  • 好评度20点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2007-11-16 09:48
我的系统是Windows Mobile 6.0,没有这个文件,麻烦给贴出来或者放上来,谢谢了。
zhengshijie
驱动小牛
驱动小牛
  • 注册日期2003-07-11
  • 最后登录2009-03-18
  • 粉丝1
  • 关注0
  • 积分8分
  • 威望217点
  • 贡献值0点
  • 好评度199点
  • 原创分3分
  • 专家分0分
地板#
发布于:2007-11-16 13:14
看你的SDK开发包中有没有storemgr.h,有的话就看一下这个文件,了解一些那些API的用法,上MSDN应该可以查到,如果没有的话那就没办法了,我没有windows mobile6.0的开发环境不能帮你测试。
zhuxiaofeng
驱动小牛
驱动小牛
  • 注册日期2007-04-06
  • 最后登录2010-04-15
  • 粉丝0
  • 关注0
  • 积分1013分
  • 威望243点
  • 贡献值0点
  • 好评度202点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2007-11-19 09:16
引用第1楼zhengshijie于2007-11-15 19:01发表的  :
如果你装有WINCE500,建议你参考WINCE500publicwceshellfeoakctlpnlstguimaindlg.cpp中的代码:
BOOL   WINAPI FormatStore(HANDLE hStore)
{
    return (PSLFormatStore(hStore) == TRUE) ? TRUE : FALSE;
}


里面貌似没有这个函数吧???

有个VOID FormatSelectedStore(HWND hDlg)

会调用到FormatStore().
做一个出色的程序员!
yanh123
驱动牛犊
驱动牛犊
  • 注册日期2007-08-03
  • 最后登录2009-08-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望31点
  • 贡献值0点
  • 好评度20点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2007-11-19 15:19
谢谢各位的热心帮助,该工具已基本搞定,我把代码贴出来。
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
#include <Storemgr.h>
#include <formatdisk.h>
#include <fatutil.h>
#include <Bootpart.h>



int wmain()
{
    STOREINFO StoreInfo={0};
    PARTINFO PartInfo = {0};
    HANDLE hFirstStore,hStore,hPart;
    HINSTANCE hFatUtil = NULL;
    BOOL    hDismount= FALSE, CPart,hPartition,hMount=FALSE;


    FORMAT_PARAMS fp={0};
    FORMAT_OPTIONS   pfo={0};
    DWORD dwClusSize = 0;
    DWORD dwFatVersion = 16;

    typedef   DWORD   (   *PFN_MY_FORMATVOLUME)  
    (HANDLE   hVolume,PDISK_INFO   pdi,   PFORMAT_OPTIONS   pfo, PFN_PROGRESS   pfnProgress,PFN_MESSAGE   pfnMessage);

    StoreInfo.cbSize = sizeof(StoreInfo);
    hFirstStore = FindFirstStore( &StoreInfo );

   if(!(hFirstStore ))
    {
        RETAILMSG(1, (TEXT("Error FindFirstStore\r\n")));

     }

      FindNextStore(hFirstStore,&StoreInfo);
      FindNextStore(hFirstStore,&StoreInfo);
      FindNextStore(hFirstStore,&StoreInfo);

      hFatUtil = LoadLibrary(L"fatutil.dll");

      PFN_MY_FORMATVOLUME   pfnFormatVolume   =  NULL  ;
    
       pfnFormatVolume =  (PFN_MY_FORMATVOLUME)GetProcAddress(hFatUtil,   TEXT( "FormatVolume"));
      if (!pfnFormatVolume )
        {
        RETAILMSG(1, (TEXT("Error pfnFormatVolumeEx\r\n")));


        }
    
      hStore = OpenStore(StoreInfo.szDeviceName);
      
      hPart = OpenPartition(hStore,L"Part00");

          
        hDismount = DismountPartition(hPart);
             if(!hDismount)
             {
               RETAILMSG(1, (TEXT("Error DismountStore\r\n")));
             }

        if(ERROR_SUCCESS   != pfnFormatVolume(hPart, NULL, NULL,   NULL,   NULL))
        {
             RETAILMSG(1, (TEXT("Error pfnFormatVolumeEx\r\n")));
        }

        

         if( !hDismount) {
              
             RETAILMSG(1, (TEXT("Error CreatePartitionEx\r\n")));
         }
          

        hMount = MountPartition(hPart);

      if(!( hMount ))
    {
        RETAILMSG(1, (TEXT("Error OpenStore\r\n")));


     }
  
    
    return 0;
}
游客

返回顶部