|
// SelectDrive.cpp : implementation file
//
#include "stdafx.h"
#include "KeyGen.h"
#include "SelectDrive.h"
#include "math.h"
#include "..\UserInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSelectDrive dialog
CSelectDrive::CSelectDrive(CWnd* pParent /*=NULL*/)
: CDialog(CSelectDrive::IDD, pParent)
{
//{{AFX_DATA_INIT(CSelectDrive)
m_nDriveIndex = -1;
//}}AFX_DATA_INIT
}
void CSelectDrive::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectDrive)
DDX_Control(pDX, IDC_DRIVE_COMBO, m_DriveCombo);
DDX_CBIndex(pDX, IDC_DRIVE_COMBO, m_nDriveIndex);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSelectDrive, CDialog)
//{{AFX_MSG_MAP(CSelectDrive)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSelectDrive message handlers
void CSelectDrive::OnOK()
{
UpdateData();
if(m_nDriveIndex<0)
{
MessageBox("Please select a flash drive","Required data missing",MB_OK|MB_ICONSTOP);
CWnd *pWnd=GetDlgItem(IDC_DRIVE_COMBO);
pWnd->SetFocus();
return;
}
m_nDrive=m_DriveCombo.GetItemData(m_nDriveIndex);
CDialog::OnOK();
}
void CSelectDrive::PopulateDriveCombo()
{
DWORD dwDrives=GetLogicalDrives();
char szVolName[MAX_PATH], szSysName[MAX_PATH];
DWORD dwVolSerialNumber, dwMaxComponentLen, dwFileSysFlags;
szVolName[0]=0;
for(int i=2;i<26;i++)
{
int bit=(int)pow((double)2,i);
if(dwDrives&bit)
{
char dr[10];
sprintf(dr,"%c:",'A'+i);
if(FIND_DRIVE_TYPE==GetDriveType(dr))
{
GetVolumeInformation(dr ,
szVolName, MAX_PATH,
&dwVolSerialNumber,
&dwMaxComponentLen, &dwFileSysFlags,
szSysName, MAX_PATH );
sprintf(dr,"%s (%c:)",szVolName,'A'+i);
int nIndex=m_DriveCombo.AddString(dr);
m_DriveCombo.SetItemData(nIndex,i);
}
}
}
if(m_DriveCombo.GetCount()==1)
m_DriveCombo.SetCurSel(0);
if(m_DriveCombo.GetCount()<1)
{
MessageBox("No removable drive found ","Error",MB_OK|MB_ICONSTOP);
CDialog::OnCancel();
}
}
BOOL CSelectDrive::OnInitDialog()
{
CDialog::OnInitDialog();
PopulateDriveCombo();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Have completed BSc in Computer Science & Engineering from Shah Jalal University of Science & Technology, Sylhet, Bangladesh (
SUST).
Story books (specially Masud Rana series), tourism, songs and programming is most favorite.
Blog:
Maruf Notes
http://blog.kuashaonline.com