关闭

VC 弹出CDRom

260人阅读 评论(0) 收藏 举报
分类:

BOOL TDevSwitch::SendSwitchCmd(BOOL bOpenDrive)
{
 DWORD MaxDriveSet = GetLogicalDrives();
 BYTE drive = 0;
 int nFindVolume = 0;
  //  [7/9/2015 dubing]
  for ( drive = 0; drive < 26; ++drive )
 {
  if ( MaxDriveSet & (1 << drive) )
  {
   TCHAR szDrive[] = _T("A:\\");
   TCHAR driveName = (TCHAR)('A'+drive);
   szDrive[0] = driveName;

   UINT driveType = GetDriveType(szDrive);

   if (driveType == DRIVE_CDROM)
   {
    TCHAR szMagicFilePath[MAX_PATH+1] = _T("A:\\InstallPackageD");
    TCHAR szMagicAppName[MAX_PATH+1] = _T("Magic");
    TCHAR szMagicKeyName[MAX_PATH+1] = _T("STRING");
    TCHAR szMagicReturn[128] = {0};
    TCHAR szMagicValue[MAX_PATH+1] = _T("su7993cka91nedc70xlampdqax862318x");

    szMagicFilePath[0] = driveName;

    TCHAR szCDROMVolume[MAX_PATH] = _T("A:\\");
    szCDROMVolume[0] = driveName;
    DWORD dwSize = 0;  
    GetDiskFreeSpace(szCDROMVolume,   NULL,   NULL,   NULL,   &dwSize);  
    if(dwSize > 0)
    {
     if(CheckFileExist_Ex(szCDROMVolume,_T("InstallPackageD"),szMagicFilePath))//(CheckFileExist(szMagicFilePath))
     {
      GetPrivateProfileString(szMagicAppName, szMagicKeyName, _T(""), szMagicReturn, sizeof(szMagicReturn) / sizeof(TCHAR), szMagicFilePath);
      if (_tcscmp(szMagicValue, szMagicReturn) == 0)
      {
       m_Volume = driveName;
       nFindVolume += CD_OpenCloseDrive(bOpenDrive, driveName) ? 1 : 0;
      }
     }
    }
   }
  }
 }

 return nFindVolume > 0;
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:80593次
    • 积分:1737
    • 等级:
    • 排名:千里之外
    • 原创:70篇
    • 转载:175篇
    • 译文:0篇
    • 评论:1条
    最新评论