关于如何调用函数SHFormatDrive的问题我已经按照网上的做法了
在header file加上#if !defined(SHFMT_OPT_FULL)
#if defined (__cplusplus)
extern "C" {
#endif DWORD WINAPI SHFormatDrive(HWND hwnd,
UINT drive,
UINT fmtID,
UINT options);
#define SHFMT_ID_DEFAULT 0xFFFF
#define SHFMT_OPT_FULL 0x0001
#define SHFMT_OPT_SYSONLY 0x0002
#define SHFMT_ERROR 0xFFFFFFFFL
// drive may be formatable
#define SHFMT_CANCEL 0xFFFFFFFEL
#define SHFMT_NOFORMAT 0xFFFFFFFDL
#if defined (__cplusplus)
}
#endif
#endif
跟着在source file内加上BOOL CFormatDriveDlg::OnInitDialog()
{
CDialog::OnInitDialog();
typedef DWORD (WINAPI *PFNSHFORMATDRIVE)(HWND hwnd,UINT drive,UINT fmtID,UINT options); PFNSHFORMATDRIVE SHFormatDrive;automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization hereHINSTANCE hInstance=LoadLibrary(_T ("E:\\PROJECT\\formatDrive\\Debug\\Shell32.dll")); if (hInstance==NULL)
AfxMessageBox("false"); SHFormatDrive=(PFNSHFORMATDRIVE)GetProcAddress(hInstance,"SHFormatDrive"); if(SHFormatDrive==NULL) { FreeLibrary(hInstance); return 1; } return TRUE; // return TRUE unless you set the focus to a control
}
void CFormatDriveDlg::OnOK()
{
// TODO: Add extra validation here
SHFormatDrive(m_hWnd,0 ,SHFMT_ID_DEFAULT, 0); FreeLibrary(hInstance);
}
为什么还不可以???????郁闷
在header file加上#if !defined(SHFMT_OPT_FULL)
#if defined (__cplusplus)
extern "C" {
#endif DWORD WINAPI SHFormatDrive(HWND hwnd,
UINT drive,
UINT fmtID,
UINT options);
#define SHFMT_ID_DEFAULT 0xFFFF
#define SHFMT_OPT_FULL 0x0001
#define SHFMT_OPT_SYSONLY 0x0002
#define SHFMT_ERROR 0xFFFFFFFFL
// drive may be formatable
#define SHFMT_CANCEL 0xFFFFFFFEL
#define SHFMT_NOFORMAT 0xFFFFFFFDL
#if defined (__cplusplus)
}
#endif
#endif
跟着在source file内加上BOOL CFormatDriveDlg::OnInitDialog()
{
CDialog::OnInitDialog();
typedef DWORD (WINAPI *PFNSHFORMATDRIVE)(HWND hwnd,UINT drive,UINT fmtID,UINT options); PFNSHFORMATDRIVE SHFormatDrive;automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization hereHINSTANCE hInstance=LoadLibrary(_T ("E:\\PROJECT\\formatDrive\\Debug\\Shell32.dll")); if (hInstance==NULL)
AfxMessageBox("false"); SHFormatDrive=(PFNSHFORMATDRIVE)GetProcAddress(hInstance,"SHFormatDrive"); if(SHFormatDrive==NULL) { FreeLibrary(hInstance); return 1; } return TRUE; // return TRUE unless you set the focus to a control
}
void CFormatDriveDlg::OnOK()
{
// TODO: Add extra validation here
SHFormatDrive(m_hWnd,0 ,SHFMT_ID_DEFAULT, 0); FreeLibrary(hInstance);
}
为什么还不可以???????郁闷
解决方案 »
- (WIN32 API)如何快速遍历并获得HDC上的一块区域的颜色
- 怎么判断一个网络连接是否是VPN连接?
- 高手指点,急需解决的问题,感激不尽
- 线程中如何给CViewABC类下的CListCtrl控件发消息?
- 什么宏可以知道目前处于Debug或Release的状态?
- 急!!!请问怎样用MFC将一幅位图显示到一个对话框的已知坐标的位置???
- 怎样由进程名得到进程ID
- 关于网络连接
- 关于C++ PRIMER 3RD里的一个范例程序在VC6里编译的问题:
- 我想把一个网站的某一页面(php页面)下载到本地系统临时目录,保存成html文件,然后分析出它的<title>,哪位好心的大虾可以根据这个要求写一段代码,感激不尽!
- [旷世难题]CToolTipCtrl 问题[2000分]
- 如何统一管理其他电脑上的测试数据?
int d=SHFormatDrive (m_hWnd, 0 ,SHFMT_ID_DEFAULT, 0);
if (d)
{
AfxMessageBox("可以");
}
else
{
AfxMessageBox("不可以");
}
结果出来是可以,但为什么格式化的dialog box没出来????????