// WipefreeSpace.cpp : Implementation of CWipefreeSpace #include "stdafx.h" #include "NSCmpts.h" #include "WipefreeSpace.h" ///////////////////////////////////////////////////////////////////////////// // CWipefreeSpace STDMETHODIMP CWipefreeSpace::InterfaceSupportsErrorInfo(REFIID riid) { static const IID* arr[] = { &IID_ISecureShutdownDOS, }; for (int i=0;ivt = VT_BSTR; bsRetVal.LoadString(IDS_WIPEFREE_NAME); pvVal->bstrVal = bsRetVal.Detach(); return S_OK; case nsHelpText: pvVal->vt = VT_BSTR; bsRetVal.LoadString(IDS_WIPEFREE_DESC); pvVal->bstrVal = bsRetVal.Detach(); return S_OK; } ::VariantClear(pvVal); return S_FALSE; } STDMETHODIMP CWipefreeSpace::SetData(IUnknown* pUnk) { return m_Data.Initialize(pUnk); } /////////////////////////////////////////////////////////////////////////////// // Property Sheet Stuff STDMETHODIMP CWipefreeSpace::Apply() { ATLTRACE(_T("CClearInetCache::Apply\n")); string sTemp; string sDrives; // If the user has selected just some drives then // save them individually if(m_bCustomDrives) { for(int nCnt = 0; nCnt < m_nDrives; nCnt++) { // Loop through check boxes if(IsDlgButtonChecked(IDC_FIRST_DRIVE + nCnt)) { // Get Label of Checked Button ::GetWindowText(GetDlgItem(IDC_FIRST_DRIVE + nCnt), sTemp.get_buffer(10), 10); sTemp.release_buffer(); // Label should be "Drive C" (C is the 7th Char) sDrives += sTemp[6]; } } } // All Drives else sDrives = _T("!!!"); m_bDirty = FALSE; return m_Data.WriteString(_T("Drives"), sDrives); } LRESULT CWipefreeSpace::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { string sDrives; string sTemp; // Get Property string sSelectedDrives = m_Data.GetString(_T("Drives"), _T("!!!")); // Has the User Changed the Defaults? m_bCustomDrives = (sSelectedDrives != _T("!!!")); ::GetLogicalDriveStrings(220, sDrives.get_buffer(220)); sDrives.release_buffer(); sSelectedDrives.make_upper(); LPCTSTR szCurDrive = sDrives; // Pointer to Current Drive in sDrives int nCnt = 0; // Current Drive Num (for interface) // Loop Through Drives while(szCurDrive[0] != _T('\0')) { // We're only interested in fixed drives if(GetDriveType(szCurDrive) == DRIVE_FIXED) { sTemp = szCurDrive; sTemp.make_upper(); // Due to interface limitations we only support 15 drives (MAX_DRIVES) if(nCnt < MAX_DRIVES) { // Give the Window the Appropriate Label SetDlgItemText(IDC_FIRST_DRIVE + nCnt, (string)(_T("Drive ") + string(sTemp[0]))); // Since it's hidden in the dialog template, show it ::ShowWindow(GetDlgItem(IDC_FIRST_DRIVE + nCnt), SW_SHOW); // Check it if the user has selected it or if we are going for all of'm CheckDlgButton(IDC_FIRST_DRIVE + nCnt, (!m_bCustomDrives) || ((sSelectedDrives.find(sTemp[0]) != string::npos))); nCnt++; } } // Next Drive szCurDrive += _tcslen(szCurDrive) + 1; // ???? Later: What does this do } // Counter for Apply() m_nDrives = nCnt; return false; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } LRESULT CWipefreeSpace::OnDrivesChange(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { // User is overriding the default m_bCustomDrives = true; return 0; }