⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgunmount.cpp

📁 一个虚拟光驱程序(驱动程序和exe)-VaporCDSource141
💻 CPP
字号:
/*
    VaporCD CD-ROM Volume Emulation for Windows NT/2000
    Copyright (C) 2000  Brad Johnson

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

    http://vaporcd.sourceforge.net/

    Brad Johnson
    3305 2nd PL #222
    Lubbock, TX 79415
*/

// DlgUnmount.cpp : implementation file
//

#include "stdafx.h"
#include "VaporCD.h"
#include "DlgUnmount.h"

#include "DlgProgress.h"

#include "vaporcd_mfc.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// DlgUnmount property page

IMPLEMENT_DYNCREATE(DlgUnmount, CPropertyPage)

DlgUnmount::DlgUnmount() : CPropertyPage(DlgUnmount::IDD)
{
	//{{AFX_DATA_INIT(DlgUnmount)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_psp.dwFlags &= ~PSP_HASHELP;
}

DlgUnmount::~DlgUnmount()
{
}

void DlgUnmount::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(DlgUnmount)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	DDX_Control(pDX, IDC_UNMOUNT_LETTER, m_cUnmountLetter);
	DDX_CBString(pDX, IDC_UNMOUNT_LETTER, m_sUnmountLetter);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(DlgUnmount, CPropertyPage)
	//{{AFX_MSG_MAP(DlgUnmount)
	ON_BN_CLICKED(IDC_UNMOUNT, OnUnmount)
	ON_CBN_DROPDOWN(IDC_UNMOUNT_LETTER, OnDropdownUnmountLetter)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// DlgUnmount message handlers





void DlgUnmount::OnUnmount() 
{
	DWORD error;

	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if (m_sUnmountLetter.GetLength() < 1 || !Unmount(m_sUnmountLetter[0]))
	{
		error = GetLastError();
		if (error == 1)
		{
			AfxMessageBox("This drive is not a VaporCD volume.");
			return;
		}
		CString s;
		s.Format("Error number %i. Durring IOCTL.",error);
		AfxMessageBox(s);
	}else
	{
		UINT nIndex;
		nIndex = m_cUnmountLetter.FindStringExact(-1,m_sUnmountLetter);
		if (nIndex!=CB_ERR)
			m_cUnmountLetter.DeleteString(nIndex);

		//
		// Success... We need to update the registry so that this drive is no
		// longer mounted on boot.
		//


		if (FALSE)
		{
			HKEY hkResult;
			LONG r1 = RegOpenKeyEx(  
				HKEY_LOCAL_MACHINE,         // handle to open key
				"SYSTEM\\CurrentControlSet\\Services\\VaporCD\\Parameters",  // address of name of subkey to open
				0,
				KEY_ALL_ACCESS,   // reserved  REGSAM samDesired, // security access mask
				&hkResult
				);

			if (r1 != ERROR_SUCCESS)
			{
				AfxMessageBox("Cannot open registry key");
				return;
			}

			// delete the key with the matching ordinal
			LONG r = RegDeleteValue(hkResult,m_sUnmountLetter);

			if (r != ERROR_SUCCESS)
			{
				// error deleting key
				AfxMessageBox("Error deleting key");
			}
			RegCloseKey(hkResult);
		}
	}
	
}

BOOL DlgUnmount::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

//
// This Updates the registry to show that we have unmounted a volume
//

BOOL DlgUnmount::RemoveMount(char cLetter)
{
/*	CString t;
	CString s = ((CVaporCDApp *)AfxGetApp())->GetProfileString("Mount","Mounted","");
	int i = s.Find(cLetter);
	if (i != -1)
	{
		// found then we remove it
		if (s.GetLength() > i+1)
			t = s.Left(i)+s.Mid(i+1);
		else
			t = s.Left(i);

		((CVaporCDApp *)AfxGetApp())-> WriteProfileString("Mount","Mounted", t);
	}*/
	return TRUE;
}


void DlgUnmount::OnDropdownUnmountLetter() 
{
	// TODO: Add extra initialization here
	m_cUnmountLetter.ResetContent();
	for (char c= 'A'; c<= 'Z' ;c++)
	{
		CString s,s1;
		s.Format("%c",c);
		s1.Format("%c:\\",c);
		int iType = GetDriveType(s1);
		if (iType == DRIVE_CDROM){
			m_cUnmountLetter.AddString(s);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -