您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetDriveType函数代码示例

51自学网 2021-06-01 21:06:54
  C++
这篇教程C++ GetDriveType函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetDriveType函数的典型用法代码示例。如果您正苦于以下问题:C++ GetDriveType函数的具体用法?C++ GetDriveType怎么用?C++ GetDriveType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetDriveType函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Q_D

QIcon QFileIconProvider::icon(const QFileInfo &info) const{    Q_D(const QFileIconProvider);    QIcon platformIcon = qt_guiPlatformPlugin()->fileSystemIcon(info);    if (!platformIcon.isNull())        return platformIcon;#if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK)    if (X11->desktopEnvironment == DE_GNOME) {        QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);        if (!gtkIcon.isNull())            return gtkIcon;    }#endif#ifdef Q_WS_MAC    QIcon retIcon = d->getMacIcon(info);    if (!retIcon.isNull())        return retIcon;#elif defined Q_WS_WIN    QIcon icon = d->getWinIcon(info);    if (!icon.isNull())        return icon;#elif defined Q_WS_HAIKU    QIcon icon = d->getHaikuIcon(info);    if (!icon.isNull())        return icon;#endif    if (info.isRoot())#if defined (Q_WS_WIN) && !defined(Q_WS_WINCE)    {        UINT type = GetDriveType((wchar_t *)info.absoluteFilePath().utf16());        switch (type) {        case DRIVE_REMOVABLE:            return d->getIcon(QStyle::SP_DriveFDIcon);        case DRIVE_FIXED:            return d->getIcon(QStyle::SP_DriveHDIcon);        case DRIVE_REMOTE:            return d->getIcon(QStyle::SP_DriveNetIcon);        case DRIVE_CDROM:            return d->getIcon(QStyle::SP_DriveCDIcon);        case DRIVE_RAMDISK:        case DRIVE_UNKNOWN:        case DRIVE_NO_ROOT_DIR:        default:            return d->getIcon(QStyle::SP_DriveHDIcon);        }    }#else    return d->getIcon(QStyle::SP_DriveHDIcon);#endif    if (info.isFile()) {        if (info.isSymLink())            return d->getIcon(QStyle::SP_FileLinkIcon);        else            return d->getIcon(QStyle::SP_FileIcon);    }  if (info.isDir()) {    if (info.isSymLink()) {      return d->getIcon(QStyle::SP_DirLinkIcon);    } else {      if (info.absoluteFilePath() == d->homePath) {        return d->getIcon(QStyle::SP_DirHomeIcon);      } else {        return d->getIcon(QStyle::SP_DirIcon);      }    }  }  return QIcon();}
开发者ID:diversys,项目名称:qt4,代码行数:72,


示例2: defined

void Engine::checkCD() {#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)	// It is a known bug under Windows that games that play CD audio cause	// ScummVM to crash if the data files are read from the same CD. Check	// if this appears to be the case and issue a warning.	// If we can find a compressed audio track, then it should be ok even	// if it's running from CD.#ifdef USE_VORBIS	if (Common::File::exists("track1.ogg") ||	    Common::File::exists("track01.ogg"))		return;#endif#ifdef USE_FLAC	if (Common::File::exists("track1.fla") ||            Common::File::exists("track1.flac") ||	    Common::File::exists("track01.fla") ||	    Common::File::exists("track01.flac"))		return;#endif#ifdef USE_MAD	if (Common::File::exists("track1.mp3") ||	    Common::File::exists("track01.mp3"))		return;#endif	char buffer[MAXPATHLEN];	int i;	const Common::FSNode gameDataDir(ConfMan.get("path"));	if (gameDataDir.getPath().empty()) {		// That's it! I give up!		if (getcwd(buffer, MAXPATHLEN) == NULL)			return;	} else		Common::strlcpy(buffer, gameDataDir.getPath().c_str(), sizeof(buffer));	for (i = 0; i < MAXPATHLEN - 1; i++) {		if (buffer[i] == '//')			break;	}	buffer[i + 1] = 0;	if (GetDriveType(buffer) == DRIVE_CDROM) {		GUI::MessageDialog dialog(			_("You appear to be playing this game directly/n"			"from the CD. This is known to cause problems,/n"			"and it is therefore recommended that you copy/n"			"the data files to your hard disk instead./n"			"See the README file for details."), _("OK"));		dialog.runModal();	} else {		// If we reached here, the game has audio tracks,		// it's not ran from the CD and the tracks have not		// been ripped.		GUI::MessageDialog dialog(			_("This game has audio tracks in its disk. These/n"			"tracks need to be ripped from the disk using/n"			"an appropriate CD audio extracting tool in/n"			"order to listen to the game's music./n"			"See the README file for details."), _("OK"));		dialog.runModal();	}#endif}
开发者ID:DouglasLiuGamer,项目名称:residualvm,代码行数:68,


示例3: GetLogicalDriveStrings

Driver *CFileServer::GetDrivers(int &Count){	try	{		TCHAR szDrivesList[256]; // Format when filled : "C:/<NULL>D:/<NULL>....Z:/<NULL><NULL>"		TCHAR szDrive[4];		TCHAR szTheDrive[32];		// TCHAR szName[255];		TCHAR szType[16];		UINT nType = 0;		DWORD dwLen;		int nIndex = 0;		dwLen = GetLogicalDriveStrings(256, szDrivesList);		Driver *driver = NULL;		Driver *p = NULL;		int k = 0;		//Add the desktop to the driver list		driver = new Driver;		if(StrCmp(gl_strLanguageId, CHINESE) == 0)			sprintf_s(driver->DriverName, "%s", szDesktop_CH);		else			sprintf_s(driver->DriverName, "%s", szDesktop_EN);		p = driver;		k ++;		if(StrCmp(gl_strLanguageId, CHINESE) == 0)			sprintf_s(szType, "%s", szLocalDisk_CH);		else			sprintf_s(szType, "%s", szLocalDisk_EN);		// Parse the list of drives			while (nIndex < (int)(dwLen - 3))		{			strcpy_s(szDrive, szDrivesList + nIndex);			nIndex += 4;			szDrive[2] = '/0'; // remove the '/'			sprintf_s(szTheDrive, "(%s)", szDrive);			// szName[0] = '/0';			szType[0] = '/0';			strcat_s(szDrive, "//");			// GetVolumeInformation(szDrive, szName, sizeof(szName), NULL, NULL, NULL, NULL, NULL);			// Get infos on the Drive (type and Name)			nType = GetDriveType(szDrive);			switch (nType)			{			case DRIVE_FIXED:				if(StrCmp(gl_strLanguageId, CHINESE) == 0)					sprintf_s(szType, "%s", szLocalDisk_CH);				else					sprintf_s(szType, "%s", szLocalDisk_EN);				break;			case DRIVE_REMOVABLE:				if(StrCmp(gl_strLanguageId, CHINESE) == 0)					sprintf_s(szType, "%s", szFloppy_CH);				else					sprintf_s(szType, "%s", szFloppy_EN);				break;			case DRIVE_CDROM:				sprintf_s(szType, "%s", "CD-ROM");				break;			case DRIVE_REMOTE:				if(StrCmp(gl_strLanguageId, CHINESE) == 0)					sprintf_s(szType, "%s", szNetDriver_CH);				else					sprintf_s(szType, "%s", szNetDriver_EN);				break;			default:				if(StrCmp(gl_strLanguageId, CHINESE) == 0)					sprintf_s(szType, "%s", szUnknowDriver_CH);				else					sprintf_s(szType, "%s", szUnknowDriver_EN);				break;			}			// Prepare it for Combo Box and add it			strcat_s(szTheDrive, " - ");			strcat_s(szTheDrive, szType);			Driver *newDriver = new Driver;			sprintf_s(newDriver->DriverName, szTheDrive);			if(NULL == driver)			{				driver = newDriver;				p = driver;			}			else			{				p->next = newDriver;				p = newDriver;			}			k++;//.........这里部分代码省略.........
开发者ID:uvbs,项目名称:myhistoryprojects,代码行数:101,


示例4: SetErrorMode

BOOL bigfilehelper::GetAllVols(std::vector<VolInfo>& vVols){    BOOL retval = FALSE;    CAtlArray<TCHAR> buffer;    TCHAR* pBuffer = NULL;    DWORD dwSize;    std::vector<CString> logicalDrvs;    CString strDrv;    POSITION pos = NULL;    POSITION max_size_pos = NULL;    ULONGLONG uMaxSize = 0;    DWORD dwSectorsPerCluster;    DWORD dwBytesPerSector;    DWORD dwNumberOfFreeClusters;    DWORD dwTotalNumberOfClusters;    TCHAR szVolName[MAX_PATH+1] = { 0 };    TCHAR szFileSystem[MAX_PATH+1] = { 0 };    BOOL fRetCode;    VolInfo volInfo;    size_t idx;    SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);    buffer.SetCount(512);    pBuffer = buffer.GetData();    dwSize = (DWORD)buffer.GetCount();    memset(pBuffer, 0, dwSize * sizeof(TCHAR));    dwSize = GetLogicalDriveStrings(dwSize, buffer.GetData());    if (dwSize > 2)    {        strDrv = pBuffer;        logicalDrvs.push_back(strDrv);        for (DWORD i = 3; i < dwSize; ++i)         {            if (pBuffer[i] != 0 && pBuffer[i - 1] == 0)             {                strDrv = pBuffer + i;                logicalDrvs.push_back(strDrv);            }        }    }    for (idx = 0; idx < logicalDrvs.size(); ++idx)    {        CString _drv = logicalDrvs[idx];        BOOL bRemovable = FALSE;        if (_drv.CompareNoCase(_T("a://")) == 0 ||             _drv.CompareNoCase(_T("b://")) == 0)        {            continue;        }        UINT uType = GetDriveType(_drv);        if (uType != DRIVE_FIXED &&            uType != DRIVE_REMOVABLE)        {            continue;        }        if (DRIVE_REMOVABLE == uType)            bRemovable = TRUE;        RtlZeroMemory(szVolName, sizeof(szVolName));        RtlZeroMemory(szFileSystem, sizeof(szFileSystem));        fRetCode = GetVolumeInformation(            _drv,            szVolName,            MAX_PATH+1,            NULL,            NULL,            NULL,            szFileSystem,            MAX_PATH+1            );        if (!fRetCode)        {            continue;        }        fRetCode = GetDiskFreeSpace(            _drv,            &dwSectorsPerCluster,            &dwBytesPerSector,            &dwNumberOfFreeClusters,            &dwTotalNumberOfClusters            );        if (!fRetCode)        {            continue;        }        volInfo.cVol = (char)_drv[0];        volInfo.strVolName = szVolName;        if (volInfo.strVolName.IsEmpty())            volInfo.strVolName = _T("本地磁盘");        volInfo.qwTotalSize = (ULONGLONG)dwTotalNumberOfClusters * dwBytesPerSector * dwSectorsPerCluster;        volInfo.qwFreeSize = (ULONGLONG)dwNumberOfFreeClusters * dwBytesPerSector * dwSectorsPerCluster;//.........这里部分代码省略.........
开发者ID:dreamsxin,项目名称:PcManager,代码行数:101,


示例5: LayThongTinODia

void LayThongTinODia(TCHAR *szODia, TCHAR *szThongTin){	// Nhung bien nay dung cho ham GetVolumeInformation	TCHAR szVolumeName[256];	DWORD DWVolumeSerialNumber;	DWORD DWMaximumComponentLength;	DWORD DWFileSystemFlags;		// Tat cac thong bao loi	SetErrorMode(SEM_FAILCRITICALERRORS);	DWErr = GetVolumeInformation(szODia, 			szVolumeName, 256,			&DWVolumeSerialNumber,			&DWMaximumComponentLength,			&DWFileSystemFlags,			NULL, 0);	if (DWErr == 0)	{		if (GetLastError() == 21) // Loi khong co dia trong o dia mem hoac CD-ROM		{			UINT t = GetDriveType(szODia);			switch (t)			{			case DRIVE_CDROM:				wcscpy_s(szVolumeName, _T("CD-ROM Drive"));				break;			case DRIVE_REMOVABLE:				wcscpy_s(szVolumeName, _T("Floppy Drive"));				break;			}		}		else			ErrorExit(_T("/"GetVolumeInformation/""));			}	// Truong hop o dia khong co ten	if (_tcslen(szVolumeName) == 0)	{		UINT t = GetDriveType(szODia);		switch (t)		{		case DRIVE_CDROM:			wcscpy_s(szVolumeName, _T("CD-ROM Drive"));			break;		case DRIVE_REMOVABLE:			wcscpy_s(szVolumeName, _T("Removable Hard Disk"));			break;		case DRIVE_RAMDISK:			wcscpy_s(szVolumeName, _T("RAM Disk"));			break;		case DRIVE_FIXED:			wcscpy_s(szVolumeName, _T("Local Disk"));			break;		}	}	szODia[2] = '/0';	wsprintf(szThongTin, _T("%s (%s)"), szVolumeName, szODia); 	szODia[2] = '//';	// Bat lai cac thong bao loi	SetErrorMode(0);}
开发者ID:anhvinhitus,项目名称:myprojects2005-2009,代码行数:64,


示例6: LogWarningF

/*** Read the options specified in the ini file.***/void MeasureDiskSpace::ReadOptions(ConfigParser& parser, const WCHAR* section){	double oldMaxValue = m_MaxValue;	Measure::ReadOptions(parser, section);	m_Drive = parser.ReadString(section, L"Drive", L"C://");	if (m_Drive.empty())	{		LogWarningF(this, L"FreeDiskSpace: Drive= empty");		m_Value = 0.0;		m_MaxValue = 0.0;		m_OldTotalBytes = 0;		m_StringValue.clear();	}	else	{		// A trailing backslash is required for GetDiskFreeSpaceEx().		PathUtil::AppendBacklashIfMissing(m_Drive);	}	m_Type = (1 == parser.ReadInt(section, L"Type", 0));	m_Total = (1 == parser.ReadInt(section, L"Total", 0));	m_Label = (1 == parser.ReadInt(section, L"Label", 0));	m_IgnoreRemovable = (1 == parser.ReadInt(section, L"IgnoreRemovable", 1));	m_DiskQuota = (1 == parser.ReadInt(section, L"DiskQuota", 1));		// Set the m_MaxValue	if (!m_Initialized)	{		BOOL result = FALSE;		ULONGLONG i64TotalBytes;		if (!m_Drive.empty())		{			const WCHAR* drive = m_Drive.c_str();			UINT type = GetDriveType(drive);			if (type != DRIVE_NO_ROOT_DIR &&				type != DRIVE_CDROM &&				(!m_IgnoreRemovable || type != DRIVE_REMOVABLE))  // Ignore CD-ROMS and removable drives			{				result = GetDiskFreeSpaceEx(drive, nullptr, (PULARGE_INTEGER)&i64TotalBytes, nullptr);			}		}		if (result)		{			m_MaxValue = (double)(__int64)i64TotalBytes;			m_OldTotalBytes = i64TotalBytes;		}		else		{			m_MaxValue = 0.0;			m_OldTotalBytes = 0;		}	}	else	{		if (m_Type)		{			m_MaxValue = DRIVETYPE_MAX;			m_OldTotalBytes = 0;		}		else		{			m_MaxValue = oldMaxValue;		}	}}
开发者ID:Geargia,项目名称:rainmeter,代码行数:73,


示例7: is_cdrom

// takes a root drive path, returns true if it is a cdrom drivebool is_cdrom(const char drive[]){	return (DRIVE_CDROM == GetDriveType(drive));}
开发者ID:Everscent,项目名称:dolphin-emu,代码行数:5,


示例8: _tmain

int _tmain(int argc, _TCHAR* argv[]){	_tprintf ( _T(" Vireio DLL link Install/Uninstall Utility/r/n"));	_tprintf ( _T(" -------------------------------------/r/n"));	_tprintf ( _T("/r/n"));	_tprintf ( _T("NOTE: THIS TOOL IS ONLY REQUIRED IF VIREIO DOES NOT INJECT WITH THE/r/n"));	_tprintf ( _T("PERCEPTION APP RUNNING WHEN YOU START THE GAME/r/n"));	_tprintf ( _T("/r/n"));	std::string instructions;	instructions += "This will create symbolic links to the Vireio DLLs in the target/r/n";	instructions += "folder rather than physically copying them./r/n";	instructions += "To uninstall the symbolic links just run this application again/r/n";	instructions += "and select the game folder and the symbolic links will be removed/r/n";	instructions += "This means if you upgrade Vireio and put it in the same location as the/r/n";	instructions += "previous version there is no need to re-run this installation tool/r/n";	instructions += "This application needs to run as Administrator to create symlinks/r/n";	instructions += "/r/n";	instructions += "** Please select target game root folder in selection dialog **/r/n";	_tprintf ( instructions.c_str());	std::string rootFolder = GetLastPath();	if (rootFolder.length() == 0)	{		std::string localDriveList;		DWORD dw = GetLogicalDrives();		char d[] = {'A', 0};		while (dw)		{			if (dw & 1)			{				std::string drive = std::string(d) + "://";				if (GetDriveType(drive.c_str()) == DRIVE_FIXED)					localDriveList += d;			}			dw = dw >> 1;			d[0]++;		}		std::vector<std::string> steamLocations;		steamLocations.push_back("://Program Files (x86)//Steam//SteamApps//common");		steamLocations.push_back("://Program Files//Steam//SteamApps//common");		steamLocations.push_back("://Steam//SteamApps//common");		bool foundPath = false;		std::string steamLocation;		for (int i = 0; (i < localDriveList.length() && !foundPath); i++)		{			//Attempt to find the right root folder			int location = 0;			while (location < (int)steamLocations.size())			{				std::string path = localDriveList[i] + steamLocations[location];				if (PathFileExists(path.c_str()))				{					foundPath = true;					steamLocation = path;					break;				}				location++;			}		}		if (!foundPath)		{			//Fail, just go to user's documents folder			PWSTR pszPath = NULL;			SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &pszPath);			char path[1024];			size_t c  = 0;			wcstombs_s(&c, path, pszPath, 1024);			rootFolder = path;		}		else			rootFolder =  steamLocation;	}
开发者ID:blast007,项目名称:Perception,代码行数:75,


示例9: GetDriveType

bool CSysInfo::GetDiskSpace(const std::string& drive,int& iTotal, int& iTotalFree, int& iTotalUsed, int& iPercentFree, int& iPercentUsed){  bool bRet= false;  ULARGE_INTEGER ULTotal= { { 0 } };  ULARGE_INTEGER ULTotalFree= { { 0 } };  if( !drive.empty() && drive != "*" )  {#ifdef TARGET_WINDOWS    UINT uidriveType = GetDriveType(( drive + "://" ).c_str());    if(uidriveType != DRIVE_UNKNOWN && uidriveType != DRIVE_NO_ROOT_DIR)      bRet= ( 0 != GetDiskFreeSpaceEx( ( drive + "://" ).c_str(), NULL, &ULTotal, &ULTotalFree) );#elif defined(TARGET_POSIX)    bRet = (0 != GetDiskFreeSpaceEx(drive.c_str(), NULL, &ULTotal, &ULTotalFree));#endif  }  else  {    ULARGE_INTEGER ULTotalTmp= { { 0 } };    ULARGE_INTEGER ULTotalFreeTmp= { { 0 } };#ifdef TARGET_WINDOWS    char* pcBuffer= NULL;    DWORD dwStrLength= GetLogicalDriveStrings( 0, pcBuffer );    if( dwStrLength != 0 )    {      dwStrLength+= 1;      pcBuffer= new char [dwStrLength];      GetLogicalDriveStrings( dwStrLength, pcBuffer );      int iPos= 0;      do {        if( DRIVE_FIXED == GetDriveType( pcBuffer + iPos  ) &&            GetDiskFreeSpaceEx( ( pcBuffer + iPos ), NULL, &ULTotal, &ULTotalFree ) )        {          ULTotalTmp.QuadPart+= ULTotal.QuadPart;          ULTotalFreeTmp.QuadPart+= ULTotalFree.QuadPart;        }        iPos += (strlen( pcBuffer + iPos) + 1 );      }while( strlen( pcBuffer + iPos ) > 0 );    }    delete[] pcBuffer;#else // for linux and osx    if( GetDiskFreeSpaceEx( "/", NULL, &ULTotal, &ULTotalFree ) )    {      ULTotalTmp.QuadPart+= ULTotal.QuadPart;      ULTotalFreeTmp.QuadPart+= ULTotalFree.QuadPart;    }#endif    if( ULTotalTmp.QuadPart || ULTotalFreeTmp.QuadPart )    {      ULTotal.QuadPart= ULTotalTmp.QuadPart;      ULTotalFree.QuadPart= ULTotalFreeTmp.QuadPart;      bRet= true;    }  }  if( bRet )  {    iTotal = (int)( ULTotal.QuadPart / MB );    iTotalFree = (int)( ULTotalFree.QuadPart / MB );    iTotalUsed = iTotal - iTotalFree;    if( ULTotal.QuadPart > 0 )    {      iPercentUsed = (int)( 100.0f * ( ULTotal.QuadPart - ULTotalFree.QuadPart ) / ULTotal.QuadPart + 0.5f );    }    else    {      iPercentUsed = 0;    }    iPercentFree = 100 - iPercentUsed;  }  return bRet;}
开发者ID:Inz999,项目名称:xbmc,代码行数:73,


示例10: nt_get_filename_info

//.........这里部分代码省略.........        /* FSCTL_GET_REPARSE_POINT? Enumerate mount points? */        g_afNtfsDrives[iDrv] = 0;        psz[0] = '//';        psz[1] = '/0';#if 1        hFile = CreateFile(pszFull,                           GENERIC_READ,                           FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,                           NULL,                           OPEN_EXISTING,                           FILE_FLAG_BACKUP_SEMANTICS,                           NULL);        if (hFile != INVALID_HANDLE_VALUE)        {            PMY_FILE_FS_ATTRIBUTE_INFORMATION pFsAttrInfo = (PMY_FILE_FS_ATTRIBUTE_INFORMATION)abBuf;            memset(&Ios, 0, sizeof(Ios));            rcNt = g_pfnNtQueryVolumeInformationFile(hFile, &Ios, abBuf, sizeof(abBuf),                                                     MY_FileFsAttributeInformation);            if (    rcNt >= 0                //&&  pFsAttrInfo->FileSystemNameLength == 4                &&  pFsAttrInfo->FileSystemName[0] == 'N'                &&  pFsAttrInfo->FileSystemName[1] == 'T'                &&  pFsAttrInfo->FileSystemName[2] == 'F'                &&  pFsAttrInfo->FileSystemName[3] == 'S'                &&  pFsAttrInfo->FileSystemName[4] == '/0')            {                memset(&Ios, 0, sizeof(Ios));                rcNt = g_pfnNtQueryVolumeInformationFile(hFile, &Ios, &g_aVolumeInfo[iDrv],                                                         sizeof(MY_FILE_FS_VOLUME_INFORMATION),                                                         MY_FileFsVolumeInformation);                if (rcNt >= 0)                {                    DWORD dwDriveType = GetDriveType(pszFull);                    if (    dwDriveType == DRIVE_FIXED                        ||  dwDriveType == DRIVE_RAMDISK)                        g_afNtfsDrives[iDrv] = 1;                }            }            CloseHandle(hFile);        }#else        {            char szFSName[32];            if (    GetVolumeInformation(pszFull,                                         NULL, 0,   /* volume name */                                         NULL,      /* serial number */                                         NULL,      /* max component */                                         NULL,      /* volume attribs */                                         szFSName,                                         sizeof(szFSName))                &&  !strcmp(szFSName, "NTFS"))            {                g_afNtfsDrives[iDrv] = 1;            }        }#endif    }    if (!g_afNtfsDrives[iDrv])        return -1;    /*     * Try open the path and query its file name information.     */    hFile = CreateFile(pszPath,                       GENERIC_READ,
开发者ID:egraba,项目名称:kbuild_openbsd,代码行数:67,


示例11: eject_drive_letter

static BOOLeject_drive_letter(WCHAR DriveLetter) {    LPWSTR szRootPath = L"X://",            szDevicePath = L"X:",            szVolumeAccessPath = L"////.//X:";    WCHAR  szDosDeviceName[MAX_PATH];    long DeviceNumber, res, tries;    HANDLE hVolume;     STORAGE_DEVICE_NUMBER sdn;    DWORD dwBytesReturned;    DEVINST DevInst;    ULONG Status;    ULONG ProblemNumber;    UINT DriveType;    PNP_VETO_TYPE VetoType;    WCHAR VetoNameW[MAX_PATH];    BOOL bSuccess;    DEVINST DevInstParent;        szRootPath[0] = DriveLetter;    szDevicePath[0] = DriveLetter;    szVolumeAccessPath[4] = DriveLetter;    DeviceNumber = -1;    hVolume = CreateFile(szVolumeAccessPath, 0,                        FILE_SHARE_READ | FILE_SHARE_WRITE,                        NULL, OPEN_EXISTING, 0, NULL);    if (hVolume == INVALID_HANDLE_VALUE) {        PyErr_SetString(PyExc_ValueError, "Invalid handle value for drive letter");        return FALSE;    }    dwBytesReturned = 0;    res = DeviceIoControl(hVolume,                        IOCTL_STORAGE_GET_DEVICE_NUMBER,                        NULL, 0, &sdn, sizeof(sdn),                        &dwBytesReturned, NULL);    if ( res ) {        DeviceNumber = sdn.DeviceNumber;    }    CloseHandle(hVolume);    if ( DeviceNumber == -1 ) {        PyErr_SetString(PyExc_ValueError, "Can't find drive number");        return FALSE;    }    res = QueryDosDevice(szDevicePath, szDosDeviceName, MAX_PATH);    if ( !res ) {       PyErr_SetString(PyExc_ValueError, "Can't find dos device");       return FALSE;    }    DriveType = GetDriveType(szRootPath);    DevInst = GetDrivesDevInstByDeviceNumber(DeviceNumber,                  DriveType, szDosDeviceName);    if (DevInst == 0) return FALSE;    DevInstParent = 0;    Status = 0;    ProblemNumber = 0;    bSuccess = FALSE;    res = CM_Get_Parent(&DevInstParent, DevInst, 0);    for ( tries = 0; tries < 3; tries++ ) {        VetoNameW[0] = 0;        res = CM_Request_Device_EjectW(DevInstParent,                &VetoType, VetoNameW, MAX_PATH, 0);        bSuccess = (res==CR_SUCCESS &&                            VetoType==PNP_VetoTypeUnknown);        if ( bSuccess )  {            break;        }        Sleep(500); // required to give the next tries a chance!    }    if (!bSuccess)  PyErr_SetString(PyExc_ValueError, "Failed to eject drive after three tries");    return bSuccess;}
开发者ID:yeyanchao,项目名称:calibre,代码行数:84,


示例12: get_all_removable_disks

BOOLget_all_removable_disks(struct tagDrives *g_drives){    WCHAR	caDrive[4];	WCHAR	volume[BUFSIZE];	int		nLoopIndex;	DWORD	dwDriveMask;	unsigned int g_count=0;	caDrive[0]	= 'A';    caDrive[1]	= ':';    caDrive[2]	= '//';    caDrive[3]	= 0;	// Get all drives in the system.    dwDriveMask = GetLogicalDrives();	if(dwDriveMask == 0)	{		PyErr_SetString(DriveError, "GetLogicalDrives failed");		return FALSE;	}	// Loop for all drives (MAX_DRIVES = 26)    for(nLoopIndex = 0; nLoopIndex < MAX_DRIVES; nLoopIndex++)    {        // if a drive is present (we cannot ignore the A and B drives as there        // are people out there that think mapping devices to use those letters        // is a good idea, sigh)		if(dwDriveMask & 1)        {            caDrive[0] = 'A' + nLoopIndex;			// If a drive is removable			if(GetDriveType(caDrive) == DRIVE_REMOVABLE)			{				//Get its volume info and store it in the global variable.				if(GetVolumeNameForVolumeMountPoint(caDrive, volume, BUFSIZE))	            {		            g_drives[g_count].letter = caDrive[0];					wcscpy_s(g_drives[g_count].volume, BUFSIZE, volume);					g_count ++;				}			}		}		dwDriveMask >>= 1;	}	// success if atleast one removable drive is found.	if(g_count == 0)	{	    PyErr_SetString(DriveError, "No removable drives found");		return FALSE;	}	return TRUE;}
开发者ID:yeyanchao,项目名称:calibre,代码行数:69,


示例13: GetSystemInfo

//.........这里部分代码省略.........         }         break;      case VER_PLATFORM_WIN32_WINDOWS:         if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)         {             strcat(sysinfo.os,"Microsoft Windows 95 ");             if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )                strcat(sysinfo.os,"OSR2 " );         }          if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)         {             strcat(sysinfo.os,"Microsoft Windows 98 ");             if ( osvi.szCSDVersion[1] == 'A' )                strcat(sysinfo.os,"SE " );         }          if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)         {             strcat(sysinfo.os,"Microsoft Windows Millennium Edition ");         }          break;    }	///////////get disk space/////////////	sysinfo.disk[0]=0;	strcat(sysinfo.disk,"磁盘空间: ");	DWORD maskdriver;	ULONGLONG totalspace=0,freespace=0;	ULONGLONG ulltotalspace,ullfreespace,freebyte;	DWORD drivertype;	char driver[10];	if(!(maskdriver=GetLogicalDrives()))		return false;	for(int i=0;i<26;i++)	{		if(!(maskdriver>>i))			break;		if(maskdriver>>i&1)		{			driver[0]=i+'A';			driver[1]=':';			driver[2]='//';			driver[3]=0;			drivertype=GetDriveType(driver);			if(drivertype!=DRIVE_FIXED)				continue;			if(!GetDiskFreeSpaceEx (driver,							(PULARGE_INTEGER)&freebyte,							(PULARGE_INTEGER)&ulltotalspace,							(PULARGE_INTEGER)&ullfreespace))							return false;			totalspace+=ulltotalspace;			freespace+=ullfreespace;		}	}	signed __int64 dfreespace=0.0,dtotalspace=0.0,lv;	dfreespace=(signed __int64)freespace/(1024*1024*1024);	dtotalspace=(signed __int64)totalspace/(1024*1024*1024);	lv=(signed __int64)freespace/totalspace*100;	char space[256];	sprintf(space,"总磁盘空间为:%.2fG,剩余磁盘空间为:%.2fG(占%.2f%c)",dtotalspace,dfreespace,lv,'%');	strcat(sysinfo.disk,space);	////////////////get cpu info//////////////////	sysinfo.processor[0]=0;	strcat(sysinfo.processor,"CPU: ");	HKEY hKey;	char szcpuinfo[80];	DWORD dwBufLen=80;	RegOpenKeyEx( HKEY_LOCAL_MACHINE,	   "HARDWARE//DESCRIPTION//System//CentralProcessor//0",	   0, KEY_QUERY_VALUE, &hKey );	RegQueryValueEx( hKey, "VendorIdentifier", NULL, NULL,	   (LPBYTE)szcpuinfo, &dwBufLen);	szcpuinfo[dwBufLen]=0;	strcat(sysinfo.processor,szcpuinfo);	strcat(sysinfo.processor," ");	memset(szcpuinfo,0,80);	dwBufLen=80;	RegQueryValueEx( hKey, "Identifier", NULL, NULL,	   (LPBYTE)szcpuinfo, &dwBufLen);	szcpuinfo[dwBufLen]=0;	strcat(sysinfo.processor,szcpuinfo);	DWORD f;	dwBufLen=8;	RegQueryValueEx( hKey, "~MHz", NULL, NULL,	   (LPBYTE)&f, &dwBufLen);	char hz[10];	sprintf(hz," %dMHZ",f);	strcat(sysinfo.processor,hz);	RegCloseKey(hKey);	/////////////get mem size////////////	MEMORYSTATUS ms;	GlobalMemoryStatus(&ms);	char membuf[256];	sprintf(membuf,"物理内存: 总物理内存:%dMB,可用内存:%dMB (占%.2f%s)",ms.dwTotalPhys/1024/1024,ms.dwAvailPhys/1024/1024		,(double)ms.dwAvailPhys/ms.dwTotalPhys*100,"%");	sysinfo.mem[0]=0;	strcpy(sysinfo.mem,membuf);	return true; }
开发者ID:dalinhuang,项目名称:screen-contorl,代码行数:101,


示例14: fileselector

int fileselector(char *name, char *path, char *filter, char *title, int filemode){  int c, d, scrrep;  int color;  int files;  int filepos = 0;  int fileview = 0;  int lastclick = 0;  int lastfile = 0;  int lowest;  int exitfilesel;  DIR *dir;  struct dirent *de;  struct stat st;  #ifdef __WIN32__  char drivestr[] = "A://";  char driveexists[26];  #endif  char cmpbuf[MAX_PATHNAME];  char tempname[MAX_PATHNAME];  // Set initial path (if any)  if (strlen(path)) chdir(path);  // Scan for all existing drives  #ifdef __WIN32__  for (c = 0; c < 26; c++)  {    drivestr[0] = 'A'+c;    if (GetDriveType(drivestr) > 1) driveexists[c] = 1;    else driveexists[c] = 0;  }  #endif  // Read new directory  NEWPATH:  getcwd(path, MAX_PATHNAME);  files = 0;  // Deallocate old names  for (c = 0; c < MAX_DIRFILES; c++)  {    if (direntry[c].name)    {      free(direntry[c].name);      direntry[c].name = NULL;    }  }  #ifdef __WIN32__  // Create drive letters  for (c = 0; c < 26; c++)  {    if (driveexists[c])    {      drivestr[0] = 'A'+c;      direntry[files].name = strdup(drivestr);      direntry[files].attribute = 2;      files++;    }  }  #endif  // Process directory  #ifdef __amigaos__  dir = opendir("");  #else  dir = opendir(".");  #endif  if (dir)  {    char *filtptr = strstr(filter, "*");    if (!filtptr) filtptr = filter;    else filtptr++;    for (c = 0; c < strlen(filter); c++)      filter[c] = tolower(filter[c]);    while ((de = readdir(dir)))    {      if ((files < MAX_DIRFILES) && (strlen(de->d_name) < MAX_FILENAME))      {        direntry[files].name = strdup(de->d_name);        direntry[files].attribute = 0;        stat(de->d_name, &st);        if (st.st_mode & S_IFDIR)        {          direntry[files].attribute = 1;          files++;        }        else        {          int c;          // If a file, must match filter          strcpy(cmpbuf, de->d_name);          if ((!strcmp(filtptr, "*")) || (!strcmp(filtptr, ".*")))            files++;          else          {            for (c = 0; c < strlen(cmpbuf); c++)              cmpbuf[c] = tolower(cmpbuf[c]);            if (strstr(cmpbuf, filtptr))//.........这里部分代码省略.........
开发者ID:suda,项目名称:goattrk2,代码行数:101,


示例15: jnm_getdriveinfo

JNIEXPORT jobject JNICALL jnm_getdriveinfo(JNIEnv *env, jobject obj, jobject file){  jclass dic = jnismooth_dll->findClass("jsmooth.DriveInfo");  if (dic == 0)    {      return NULL;    }  jmethodID construc = jnismooth_dll->findMethod(dic, "<init>", "()V", false);  if (construc == 0)    {      return NULL;    }  JMethodCaller canonicalcaller("java.io.File", "java.lang.String getCanonicalPath()");  jvalue vals[0];  jvalue canonicalval = canonicalcaller.invoke(*jnismooth_dll, file, vals);  jstring jcanstr = (jstring)canonicalval.l;  jboolean copy = true;  const char* str = jnismooth_dll->env()->GetStringUTFChars(jcanstr, &copy);  std::string canonicalfile = str;  jnismooth_dll->env()->ReleaseStringUTFChars(jcanstr, str);  //  int driveType = GetDriveType();  jobject driveinfo = jnismooth_dll->env()->NewObject(dic, construc);  if ((canonicalfile.length()>1) && (canonicalfile[1] == ':'))    {      std::string driveletter = canonicalfile[0] + std::string("://");      int drivetype = GetDriveType(driveletter.c_str());      jnismooth_dll->setIntField(dic, driveinfo, "m_driveType", drivetype);      void * pGetDiskFreeSpaceEx = (void*)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetDiskFreeSpaceExA");      long freeBytes = 0, totalBytes = -1, totalFreeBytes = 0;      if ((pGetDiskFreeSpaceEx != 0) && (drivetype > 1))	{	  unsigned __int64 lpFreeBytesAvailable, lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes;	  if (GetDiskFreeSpaceEx(driveletter.c_str(), (_ULARGE_INTEGER*)&lpFreeBytesAvailable, (_ULARGE_INTEGER*)&lpTotalNumberOfBytes, (_ULARGE_INTEGER*)&lpTotalNumberOfFreeBytes))	    {	      freeBytes = lpFreeBytesAvailable;	      totalBytes = lpTotalNumberOfBytes;	      totalFreeBytes = lpTotalNumberOfFreeBytes;	    }	}      else if (drivetype > 1)	{	  DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters;	  if (GetDiskFreeSpace(driveletter.c_str(), &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters))	    {	      freeBytes = ((long)dwBytesPerSect * (long)dwSectPerClust * (long)dwFreeClusters);	      totalBytes = ((long)dwBytesPerSect * (long)dwSectPerClust * (long)dwTotalClusters);	      totalFreeBytes = ((long)dwBytesPerSect * (long)dwSectPerClust * (long)dwFreeClusters);	    }	}      jnismooth_dll->setLongField(dic, driveinfo, "m_freeBytesForUser", freeBytes);            jnismooth_dll->setLongField(dic, driveinfo, "m_totalFreeBytes", totalFreeBytes);            jnismooth_dll->setLongField(dic, driveinfo, "m_totalBytes", totalBytes);            if (drivetype > 1)	{	  char volumename[MAX_PATH+1], filesystemname[MAX_PATH+1];	  DWORD serialnumber, maxcomposize, systemflags;	  if (GetVolumeInformation( driveletter.c_str(), volumename, MAX_PATH, 				    &serialnumber, &maxcomposize, &systemflags,				    filesystemname, MAX_PATH))	    {	      jnismooth_dll->setIntField(dic, driveinfo, "m_serialNumber", serialnumber);	      jnismooth_dll->setIntField(dic, driveinfo, "m_maxComponentSize", maxcomposize);	      jnismooth_dll->setIntField(dic, driveinfo, "m_systemFlags", systemflags);	      jstring jvolumename = jnismooth_dll->newUTFString(volumename);	      jstring jfilesystemname = jnismooth_dll->newUTFString(filesystemname);	      jnismooth_dll->setObjectField(dic, driveinfo, "m_volumeName", "java.lang.String", (jobject)jvolumename);	      jnismooth_dll->setObjectField(dic, driveinfo, "m_fileSystemName", "java.lang.String", (jobject)jfilesystemname);	    }	  	}    }      //  jfieldID binding = broker->env()->GetFieldID(nat, "m_", "I");  // broker->env()->SetStaticBooleanField(nat, binding, JNI_TRUE);  return driveinfo;}
开发者ID:jamesdlow,项目名称:jsmooth,代码行数:87,


示例16: IsRemote

		virtual bool IsRemote(char drive) const		{			char driveName[] = { drive, ':', '//', '/0' };			UINT type = GetDriveType(driveName);			return (type==DRIVE_REMOTE);		}
开发者ID:MarkVanPeteghem,项目名称:ModAssert,代码行数:6,


示例17: CreateWindowEx

BOOL GetLogicalDrivers::Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam){	hComboBox = CreateWindowEx(WS_EX_DLGMODALFRAME, TEXT("COMBOBOX"), 0,		WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST|CBS_SORT, 50, 50, 300, 400, hwnd, 0, HINSTANCE(ptr), 0);		const DWORD number_of_drives = 32;	TCHAR buffer[512];	TCHAR* b_ptr;	b_ptr = buffer;	GetLogicalDriveStrings(number_of_drives, buffer);	TCHAR letter = char(65);	int i = 1;	int mask = GetLogicalDrives();	//TCHAR textt[10];	//wsprintf(textt, TEXT("%d"), mask);	//MessageBox(hDialog, textt, TEXT("INFO"), MB_OK);	while (*b_ptr)	{		while (b_ptr[0] != letter)		{			letter = char(65 + i);			++i;		}		int n = ((mask >> i) & 0x00000001);		if (!n)		{			b_ptr = b_ptr + wcslen(b_ptr) + 1;			continue;		}				int type = GetDriveType(b_ptr);		TCHAR type_name[16];		switch (type)		{		case DRIVE_FIXED:			lstrcpy(type_name, TEXT(" (fixed)"));			break;		case DRIVE_REMOVABLE:			lstrcpy(type_name, TEXT(" (removable)"));			break;		case DRIVE_REMOTE:			lstrcpy(type_name, TEXT(" (remote)"));			break;		case DRIVE_CDROM:			lstrcpy(type_name, TEXT(" (cd-rom)"));			break;		case DRIVE_RAMDISK:			lstrcpy(type_name, TEXT(" (virtual)"));			break;		default:			lstrcpy(type_name, TEXT(" (unknown)"));			break;		}		TCHAR temp[32];		lstrcpy(temp, b_ptr);		lstrcat(temp, type_name);		SendMessage(hComboBox, CB_ADDSTRING, 0, LPARAM(temp));		b_ptr = b_ptr + wcslen(b_ptr) + 1;	}			return TRUE;}
开发者ID:NikitaVas,项目名称:WinAPI,代码行数:64,


示例18: getNotesOnLogicalDrive

static UTF16 getNotesOnLogicalDrive(Error& error, const UTF16& sLogicalDrive){	UTF16Buffer sbVolName(MAX_PATH+1);	UTF16Buffer sbFSType(MAX_PATH+1);	if (!GetVolumeInformation(sLogicalDrive.ptr(), sbVolName.ptr(), 		sbVolName.flength(), NULL, NULL, NULL, sbFSType.ptr(), sbFSType.flength()))	{		error.what(WindowsError::getLastError());		error.who(L"GetVolumeInformation");		return UTF16();	}		UTF16 sVolName = sbVolName;	UTF16 sFSType = sbFSType;	if (!sVolName.empty())		sVolName = sVolName + " ";		if (!sFSType.empty())		sFSType = sFSType + " ";	UTF16 sDriveType;	switch (GetDriveType(sLogicalDrive.ptr()))	{	case DRIVE_NO_ROOT_DIR: sDriveType = L"No Root Dir "; break;	case DRIVE_REMOVABLE: sDriveType = L"Removable "; break;	case DRIVE_FIXED: sDriveType = L"Fixed "; break;	case DRIVE_CDROM: sDriveType = L"CDROM "; break;	case DRIVE_RAMDISK: sDriveType = L"RAM Disk "; break;	default: sDriveType = L"Unknown ";	}	UTF16 sSizeInfo;	UInt64 iBytesFree, iTotalBytes;	ULARGE_INTEGER ulgFreeBytesAvailable, ulgTotalNumberOfBytes;	if (GetDiskFreeSpaceEx(sLogicalDrive.ptr(), &ulgFreeBytesAvailable, &ulgTotalNumberOfBytes, NULL))	{		iBytesFree = ulgFreeBytesAvailable.QuadPart;		iTotalBytes = ulgTotalNumberOfBytes.QuadPart;		int iUnit = 0;		for (UInt64 i = iTotalBytes; i > 0; i >>= 10)			iUnit++;		UTF16 sUnit;		switch (iUnit)		{		case 0: iUnit = 1; sUnit = L"B"; break;		case 1: sUnit = L"B"; break;		case 2: sUnit = L"KB"; break;		case 3: sUnit = L"MB"; break;		case 4: sUnit = L"GB"; break;		case 5: sUnit = L"TB"; break;		case 6: sUnit = L"PB"; break;		case 7: sUnit = L"EB"; break;		case 8: sUnit = L"ZB"; break;		case 9: sUnit = L"YB"; break;		default: sUnit = L"??"; break;		}		Real64 fBytesFree = Real64(iBytesFree) / Real64(1ULL << (10*(iUnit-1)));		Real64 fTotalBytes = Real64(iTotalBytes) / Real64(1ULL << (10*(iUnit-1)));		Real64 fBytesUsed = fTotalBytes - fBytesFree;		sSizeInfo = UTF16::format(L"%d/%d%s ", UInt32(fBytesUsed), UInt32(fTotalBytes), sUnit.ptr());	}
开发者ID:tomazos,项目名称:Folderscope,代码行数:68,


示例19: IsDirectory

INT IsDirectory(LPCWSTR szDirectoryName){		HANDLE hFind;	WIN32_FIND_DATAW fd;		int ret=TRUE;		if (szDirectoryName[0]==L'/0')		return 0;		if (szDirectoryName[1]==L'/0')		return 0;		if (szDirectoryName[2]==L'/0')		return 0;		if (szDirectoryName[1]==L':' && szDirectoryName[2]==L'//' && szDirectoryName[3]==L'/0')	{		switch (GetDriveTypeW(szDirectoryName))		{		case DRIVE_UNKNOWN:		case DRIVE_NO_ROOT_DIR:			return 0;		case DRIVE_FIXED:			return 1;		default:			return 2;		}	}			// Taking last '//' 	LPWSTR szPath;	SIZE_T dwPathLen=istrlenw(szDirectoryName);	if (szDirectoryName[dwPathLen-1]==L'//' && dwPathLen>3)	{		szPath=new WCHAR[dwPathLen+5];		--dwPathLen;		MemCopyW(szPath,szDirectoryName,dwPathLen);		szPath[dwPathLen]='/0';	}	else		szPath=LPWSTR(szDirectoryName);		hFind=FindFirstFileW(szPath,&fd);	if (hFind!=INVALID_HANDLE_VALUE)	{		while (!(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && ret)			ret=FindNextFileW(hFind,&fd);			if (szPath!=szDirectoryName)			delete[] szPath;		FindClose(hFind);			if (ret)		{			if (szDirectoryName[0]==L'//')			{				if (szDirectoryName[1]==L'//')					return 2;				switch (GetDriveType(NULL))				{				case DRIVE_UNKNOWN:				case DRIVE_NO_ROOT_DIR:					return 0;				case DRIVE_FIXED:					return 1;				default:					return 2;				} 			}			if (szDirectoryName[1]==L':' && szDirectoryName[2]==L'//')			{				WCHAR szTemp[4]=L"X://";				szTemp[0]=szDirectoryName[0];				switch (GetDriveTypeW(szTemp))				{				case DRIVE_UNKNOWN:					return 0;				case DRIVE_FIXED:					return 1;				default:					return 2;				}			}		}		return 0;	}	else if (szDirectoryName[0]==L'//' && szDirectoryName[1]==L'//')	{				// UNC share name		if (szPath==szDirectoryName)//.........这里部分代码省略.........
开发者ID:joshball,项目名称:locate32-cogit.net,代码行数:101,


示例20: GetDriveType

/*** Updates the current disk free space value.***/void MeasureDiskSpace::UpdateValue(){	if (!m_Drive.empty())	{		const WCHAR* drive = m_Drive.c_str();		UINT type = GetDriveType(drive);		if (m_Type)		{			switch (type)			{			case DRIVE_UNKNOWN:			case DRIVE_NO_ROOT_DIR:				m_Value = DRIVETYPE_REMOVED;				m_StringValue = L"Removed";				break;			case DRIVE_REMOVABLE:				m_Value = DRIVETYPE_REMOVABLE;				m_StringValue = L"Removable";				break;			case DRIVE_FIXED:				m_Value = DRIVETYPE_FIXED;				m_StringValue = L"Fixed";				break;			case DRIVE_REMOTE:				m_Value = DRIVETYPE_NETWORK;				m_StringValue = L"Network";				break;			case DRIVE_CDROM:				m_Value = DRIVETYPE_CDROM;				m_StringValue = L"CDRom";				break;			case DRIVE_RAMDISK:				m_Value = DRIVETYPE_RAM;				m_StringValue = L"Ram";				break;			default:				m_Value = DRIVETYPE_ERROR;				m_StringValue = L"Error";				break;			}		}		else		{			BOOL sizeResult = FALSE;			ULONGLONG i64TotalBytes, i64FreeBytes;			if (type != DRIVE_NO_ROOT_DIR &&				type != DRIVE_CDROM &&				(!m_IgnoreRemovable || type != DRIVE_REMOVABLE))  // Ignore CD-ROMS and removable drives			{				if (!m_DiskQuota)				{					sizeResult = GetDiskFreeSpaceEx(drive, nullptr, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);				}				else				{					sizeResult = GetDiskFreeSpaceEx(drive, (PULARGE_INTEGER)&i64FreeBytes, (PULARGE_INTEGER)&i64TotalBytes, nullptr);				}			}			if (sizeResult)			{				m_Value = (double)(__int64)((m_Total) ? i64TotalBytes : i64FreeBytes);				if (i64TotalBytes != m_OldTotalBytes)				{					// Total size was changed, so set new max value.					m_MaxValue = (double)(__int64)i64TotalBytes;					m_OldTotalBytes = i64TotalBytes;				}			}			else			{				m_Value = 0.0;				m_MaxValue = 0.0;				m_OldTotalBytes = 0;			}			if (m_Label)			{				BOOL labelResult = FALSE;				WCHAR volumeName[MAX_PATH + 1];				if (type != DRIVE_NO_ROOT_DIR &&					(!m_IgnoreRemovable || type != DRIVE_REMOVABLE))  // Ignore removable drives				{					labelResult = GetVolumeInformation(drive, volumeName, MAX_PATH + 1, nullptr, nullptr, nullptr, nullptr, 0);				}				m_StringValue = (labelResult) ? volumeName : L"";			}			else if (!m_StringValue.empty())			{				m_StringValue.clear();			}//.........这里部分代码省略.........
开发者ID:Geargia,项目名称:rainmeter,代码行数:101,


示例21: init_posix_emu

// !!UNCvoid init_posix_emu(void){	if(!validate_stat_struct) {		ErrorAlert( "Invalid struct my_stat -- edit posix_emu.h" );		QuitEmulator();	}#if DEBUG_EXTFS	debug_extfs = PrefsFindInt16("debugextfs");	debug_extfs = DB_EXTFS_LOUD;	if(debug_extfs != DB_EXTFS_NONE) {		extfs_log_open( EXTFS_LOG_FILE_NAME );	}#endif	// We cannot use ExtFS "RootPath" because of the virtual desktop.	if(PrefsFindBool("enableextfs")) {		PrefsReplaceString("extfs", "");	} else {		PrefsRemoveItem("extfs");		D(bug("extfs disabled by user/n"));#if DEBUG_EXTFS		extfs_log_close();#endif		return;	}	const char *extdrives = PrefsFindString("extdrives");	// Set up drive list.	size_t outinx = 0;	for( TCHAR letter = TEXT('A'); letter <= TEXT('Z'); letter++ ) {		if(extdrives && !strchr(extdrives,letter)) continue;		TCHAR rootdir[20];		_sntprintf( rootdir, lengthof(rootdir), TEXT("%c://"), letter );		use_streams[ letter - 'A' ] = false;		switch(GetDriveType(rootdir)) {			case DRIVE_FIXED:			case DRIVE_REMOTE:			case DRIVE_RAMDISK:				// TODO: NTFS AFP?				// fall			case DRIVE_REMOVABLE:			case DRIVE_CDROM:				if(outinx < lengthof(host_drive_list)) {					host_drive_list[outinx] = letter;					outinx += 2;				}		}	}	// Set up virtual desktop root.	// TODO: this should be customizable.	GetModuleFileName( NULL, virtual_root, lengthof(virtual_root) );	TCHAR *p = _tcsrchr( virtual_root, TEXT('//') );	if(p) {		_tcscpy( ++p, desktop_name );	} else {		// should never happen		_sntprintf( virtual_root, lengthof(virtual_root), TEXT("C://%s"), desktop_name );	}	CreateDirectory( virtual_root, 0 );	// Set up an icon looking like "My Computer"	// Can be overwritten just like any other folder custom icon.	if(my_access(custom_icon_name,0) != 0) {		int fd = my_creat( custom_icon_name, 0 );		if(fd >= 0) {			my_close(fd);			fd = open_rfork( custom_icon_name, O_RDWR|O_CREAT );			if(fd >= 0) {				my_write( fd, my_comp_icon, sizeof(my_comp_icon) );				my_close(fd);				static uint8 host_finfo[SIZEOF_FInfo];				uint32 finfo = Host2MacAddr(host_finfo);				get_finfo(custom_icon_name, finfo, 0, false);				WriteMacInt16(finfo + fdFlags, kIsInvisible);				set_finfo(custom_icon_name, finfo, 0, false);				get_finfo(my_computer, finfo, 0, true);				WriteMacInt16(finfo + fdFlags, ReadMacInt16(finfo + fdFlags) | kHasCustomIcon);				set_finfo(my_computer, finfo, 0, true);			} else {				my_remove(custom_icon_name);			}		}	}}
开发者ID:DavidLudwig,项目名称:macemu,代码行数:90,


示例22: ScanForCdromDevices

DWORDScanForCdromDevices(    VOID    )/*++Routine Description:    Scan through device chain for CDROM devices.  For each one    that is found, allocate storage in the gDevices array and    fill in fields available at this time.Arguments:    noneReturn Value:    Number of CDROM devices found.--*/{    CHAR        DriveRoot[]="A://", DevRoot[]="////.//A:";    int         NumCdroms;    HANDLE      TmpHandle;    DWORD       dwDrives;    CHAR        s[255];    //    // Find what drive letters are valid    //    dwDrives = GetLogicalDrives();    NumCdroms = 0;    //    // Loop through drives letters one by one, checking to see if it's a Cdrom.    //    for ( DriveRoot[0]='A'; dwDrives != 0; dwDrives = dwDrives>>1 ) {        //        // If the current DriveLetter Exists and is a Cdrom        //        if ( (dwDrives & 0x1) && (GetDriveType(DriveRoot) == DRIVE_CDROM) ) {            DevRoot[4] = DriveRoot[0];            if ((NumCdroms < (INT)gNumCdDevices) && (gDevices[NumCdroms]!=NULL)) {                LocalFree( (HLOCAL)gDevices[ NumCdroms ] );            }            gDevices[ NumCdroms ] = (PCDROM)LocalAlloc( LPTR, sizeof( CDROM ) );            if (gDevices[ NumCdroms ]==NULL) {                sprintf( s, IdStr( STR_NO_RES ), GetLastError() );                MyFatalExit( s );            }            gDevices[ NumCdroms ]->drive = DriveRoot[0];            gDevices[ NumCdroms ]->State = NO_CD;            //            // Open the Cdrom for exclusive access            //            TmpHandle = CreateFile( DevRoot,                                    GENERIC_READ,                                    FILE_SHARE_READ,                                    NULL,                                    OPEN_EXISTING,                                    FILE_ATTRIBUTE_NORMAL,                                    NULL                                   );            if (TmpHandle == INVALID_HANDLE_VALUE) {                gDevices[ NumCdroms ]->hCd = NULL;            } else {                gDevices[ NumCdroms ]->hCd = TmpHandle;            }//.........这里部分代码省略.........
开发者ID:mingpen,项目名称:OpenNT,代码行数:101,


示例23: defined

// HasEnoughDiskSpace//------------------------------------------------------------------------------bool Worker::HasEnoughDiskSpace(){    #if defined( __WINDOWS__ )        // Only check disk space every few seconds        float elapsedTime = m_TimerLastDiskSpaceCheck.GetElapsedMS();        if ( ( elapsedTime < 15000.0f ) && ( m_LastDiskSpaceResult != -1 ) )        {            return ( m_LastDiskSpaceResult != 0 );        }        m_TimerLastDiskSpaceCheck.Start();                 static const uint64_t MIN_DISK_SPACE = 1024 * 1024 * 1024; // 1 GiB                  DWORD logicalDrives = GetLogicalDrives();        DWORD driveMask = 1;        char driveLetter = 'a';        char drivePath[32];        int validDriveCount = 0;    // This is to insure we find at least one drive...                 // Enumerate all drive letters.        for ( uint32_t i = 0; i < 26; ++i, ++driveLetter, driveMask *= 2 )        {            if ( (logicalDrives & driveMask) != 0 )            {                // This letter is used.                sprintf_s( drivePath, sizeof(drivePath), "%c://", driveLetter );                         UINT driveType = GetDriveType( drivePath );                if ( driveType == DRIVE_FIXED )                {                    // This is a fixed frive.                    unsigned __int64 freeBytesAvailable = 0;                    unsigned __int64 totalNumberOfBytes = 0;                    unsigned __int64 totalNumberOfFreeBytes = 0;                             // Check available disk space                    BOOL result = GetDiskFreeSpaceExA( drivePath, (PULARGE_INTEGER)&freeBytesAvailable, (PULARGE_INTEGER)&totalNumberOfBytes, (PULARGE_INTEGER)&totalNumberOfFreeBytes );                    if ( result )                    {                        if ( freeBytesAvailable < MIN_DISK_SPACE )                        {                            // The drive doesn't have enough free space. Exclude this machine from workers.                            // It is simpler to exclude the machine from the build when any of its drive has not enough space                            // than trying to figure out which drives are really used by Fastbuild especially in the context of symlinks, hardlinks, etc...                            m_LastDiskSpaceResult = 0;                            return false;                        }                                 // At least one drive found.                        ++validDriveCount;                    }                    else                    {                        // There is something wrong with the drives...                        m_LastDiskSpaceResult = 0;                        return false;                    }                }            }        }                // return true if we've found at least one disk drive.         // This is paranoid but I like being paranoid. If we reach this line it is pretty much impossible for validDriveCount to be 0.            m_LastDiskSpaceResult = validDriveCount > 0;        return m_LastDiskSpaceResult != 0;    #else        return true; // TODO:MAC TODO:LINUX Implement disk space checks    #endif}
开发者ID:jujis008,项目名称:fastbuild,代码行数:71,


示例24: is_cdrom

// takes a root drive path, returns true if it is a cdrom drivebool is_cdrom(const TCHAR* drive){    return (DRIVE_CDROM == GetDriveType(drive));}
开发者ID:gamax92,项目名称:Ishiiruka,代码行数:5,


示例25: super

FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info) :	super(hwnd, info){	CONTEXT("FileChildWindow::FileChildWindow()");	TCHAR drv[_MAX_DRIVE+1];	Entry* entry = NULL;	_left = NULL;	_right = NULL;	switch(info._etype) {#ifdef __WINE__	  case ET_UNIX:		_root._drive_type = GetDriveType(info._path);		_root._sort_order = SORT_NAME;		_tsplitpath(info._path, drv, NULL, NULL, NULL);		lstrcat(drv, TEXT("/"));		lstrcpy(_root._volname, TEXT("root fs"));		_root._fs_flags = 0;		lstrcpy(_root._fs, TEXT("unixfs"));		lstrcpy(_root._path, TEXT("/"));		_root._entry = new UnixDirectory(_root._path);		entry = _root.read_tree(info._path+_tcslen(_root._path));		break;#endif	  case ET_NTOBJS:		_root._drive_type = DRIVE_UNKNOWN;		_root._sort_order = SORT_NAME;		_tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0);		lstrcat(drv, TEXT("//"));		lstrcpy(_root._volname, TEXT("NT Object Namespace"));		lstrcpy(_root._fs, TEXT("NTOBJ"));		lstrcpy(_root._path, drv);		_root._entry = new NtObjDirectory(_root._path);		entry = _root.read_tree(info._path+_tcslen(_root._path));		break;	  case ET_REGISTRY:		_root._drive_type = DRIVE_UNKNOWN;		_root._sort_order = SORT_NONE;		_tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0);		lstrcat(drv, TEXT("//"));		lstrcpy(_root._volname, TEXT("Registry"));		lstrcpy(_root._fs, TEXT("Registry"));		lstrcpy(_root._path, drv);		_root._entry = new RegistryRoot();		entry = _root.read_tree(info._path+_tcslen(_root._path));		break;	  case ET_FAT: {		_root._drive_type = DRIVE_UNKNOWN;		_root._sort_order = SORT_NONE;		_tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0);		lstrcat(drv, TEXT("//"));		lstrcpy(_root._volname, TEXT("FAT XXX"));	//@@		lstrcpy(_root._fs, TEXT("FAT"));		lstrcpy(_root._path, drv);		FATDrive* drive = new FATDrive(TEXT("c:/odyssey-emu/c.img"));	//TEXT("////.//F:"));	//@@		if (drive->_hDrive != INVALID_HANDLE_VALUE) {			_root._entry = drive;			entry = _root.read_tree(info._path+_tcslen(_root._path));		}		break;}#ifndef _NO_WIN_FS	  default:	// ET_WINDOWS		_root._drive_type = GetDriveType(info._path);		_root._sort_order = SORT_NAME;		_tsplitpath_s(info._path, drv, COUNTOF(drv), NULL, 0, NULL, 0, NULL, 0);		lstrcat(drv, TEXT("//"));		GetVolumeInformation(drv, _root._volname, _MAX_FNAME, 0, 0, &_root._fs_flags, _root._fs, COUNTOF(_root._fs));		lstrcpy(_root._path, drv);		_root._entry = new WinDirectory(_root._path);		entry = _root.read_tree(info._path+_tcslen(_root._path));		break;#else	default:#endif	  case ET_SHELL: {	//@@ separate FileChildWindow into ShellChildWindow, WinChildWindow, UnixChildWindow ?		_root._drive_type = DRIVE_UNKNOWN;		_root._sort_order = SORT_NAME;		lstrcpy(drv, TEXT("//"));		lstrcpy(_root._volname, TEXT("Desktop"));		_root._fs_flags = 0;		lstrcpy(_root._fs, TEXT("Shell"));		_root._entry = new ShellDirectory(GetDesktopFolder(), DesktopFolderPath(), hwnd);		const ShellChildWndInfo& shell_info = static_cast<const ShellChildWndInfo&>(info);		entry = _root.read_tree(&*shell_info._shell_path);		break;}//.........这里部分代码省略.........
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:101,


示例26: GetDriveType

bool CSysInfo::GetDiskSpace(const CStdString drive,int& iTotal, int& iTotalFree, int& iTotalUsed, int& iPercentFree, int& iPercentUsed){  bool bRet= false;  ULARGE_INTEGER ULTotal= { { 0 } };  ULARGE_INTEGER ULTotalFree= { { 0 } };  if( !drive.IsEmpty() && !drive.Equals("*") )  {#ifdef _WIN32    UINT uidriveType = GetDriveType(( drive + "://" ));    if(uidriveType != DRIVE_UNKNOWN && uidriveType != DRIVE_NO_ROOT_DIR)#endif      bRet= ( 0 != GetDiskFreeSpaceEx( ( drive + "://" ), NULL, &ULTotal, &ULTotalFree) );  }  else  {    ULARGE_INTEGER ULTotalTmp= { { 0 } };    ULARGE_INTEGER ULTotalFreeTmp= { { 0 } };#ifdef _WIN32    char* pcBuffer= NULL;    DWORD dwStrLength= GetLogicalDriveStrings( 0, pcBuffer );    if( dwStrLength != 0 )    {      dwStrLength+= 1;      pcBuffer= new char [dwStrLength];      GetLogicalDriveStrings( dwStrLength, pcBuffer );      int iPos= 0;      do {        if( DRIVE_FIXED == GetDriveType( pcBuffer + iPos  ) &&            GetDiskFreeSpaceEx( ( pcBuffer + iPos ), NULL, &ULTotal, &ULTotalFree ) )        {          ULTotalTmp.QuadPart+= ULTotal.QuadPart;          ULTotalFreeTmp.QuadPart+= ULTotalFree.QuadPart;        }        iPos += (strlen( pcBuffer + iPos) + 1 );      }while( strlen( pcBuffer + iPos ) > 0 );    }    delete[] pcBuffer;#else // for linux and osx    static const char *drv_letter[] = { "C://", "E://", "F://", "G://", "X://", "Y://", "Z://", NULL };    for( int i = 0; drv_letter[i]; i++)    {      if( GetDiskFreeSpaceEx( drv_letter[i], NULL, &ULTotal, &ULTotalFree ) )      {        ULTotalTmp.QuadPart+= ULTotal.QuadPart;        ULTotalFreeTmp.QuadPart+= ULTotalFree.QuadPart;      }    }#endif    if( ULTotalTmp.QuadPart || ULTotalFreeTmp.QuadPart )    {      ULTotal.QuadPart= ULTotalTmp.QuadPart;      ULTotalFree.QuadPart= ULTotalFreeTmp.QuadPart;      bRet= true;    }  }  if( bRet )  {    iTotal = (int)( ULTotal.QuadPart / MB );    iTotalFree = (int)( ULTotalFree.QuadPart / MB );    iTotalUsed = iTotal - iTotalFree;    iPercentUsed = (int)( 100.0f * ( ULTotal.QuadPart - ULTotalFree.QuadPart ) / ULTotal.QuadPart + 0.5f );    iPercentFree = 100 - iPercentUsed;  }  return bRet;}
开发者ID:AWilco,项目名称:xbmc,代码行数:68,


示例27: _tmain

//----------------------------------------------------------------------//// WMain//// Engine. Just get command line switches and fire off a format. This// could also be done in a GUI like Explorer does when you select a// drive and run a check on it.//// We do this in UNICODE because the chkdsk command expects PWCHAR// arguments.////----------------------------------------------------------------------int_tmain(int argc, TCHAR *argv[]){	int badArg;	DWORD media = FMIFS_HARDDISK;	DWORD driveType;	TCHAR fileSystem[1024];	TCHAR volumeName[1024];	TCHAR input[1024];	DWORD serialNumber;	DWORD flags, maxComponent;	ULARGE_INTEGER freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes;#ifndef UNICODE	WCHAR RootDirectoryW[MAX_PATH], FormatW[MAX_PATH], LabelW[MAX_PATH];#endif	TCHAR szMsg[RC_STRING_MAX_SIZE];	//	// Get function pointers	//	if( !LoadFMIFSEntryPoints()) {		LoadStringAndOem( GetModuleHandle(NULL), STRING_FMIFS_FAIL, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);		_tprintf("%s", szMsg);		return -1;	}	//	// Parse command line	//	if( (badArg = ParseCommandLine( argc, argv ))) {		LoadStringAndOem( GetModuleHandle(NULL), STRING_UNKNOW_ARG, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);		_tprintf(szMsg, argv[badArg] );		Usage(argv[0]);		return -1;	}	//	// Get the drive's format	//	if( !Drive ) {		LoadStringAndOem( GetModuleHandle(NULL), STRING_DRIVE_PARM, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);		_tprintf(szMsg);		Usage( argv[0] );		return -1;	} else {		_tcscpy( RootDirectory, Drive );	}	RootDirectory[2] = _T('//');	RootDirectory[3] = _T('/0');	//	// See if the drive is removable or not	//	driveType = GetDriveType( RootDirectory );	if( driveType == 0 ) {		LoadStringAndOem( GetModuleHandle(NULL), STRING_ERROR_DRIVE_TYPE, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);		PrintWin32Error( szMsg, GetLastError());		return -1;	}	else if ( driveType == 1 )	{		LoadString( GetModuleHandle(NULL), STRING_NO_VOLUME, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);		PrintWin32Error( szMsg, GetLastError());		return -1;	}	if( driveType != DRIVE_FIXED ) {		LoadStringAndOem( GetModuleHandle(NULL), STRING_INSERT_DISK, (LPTSTR) szMsg,RC_STRING_MAX_SIZE);		_tprintf(szMsg, RootDirectory[0] );		_fgetts( input, sizeof(input)/2, stdin );		media = FMIFS_FLOPPY;	}	//	// Determine the drive's file system format	//	if( !GetVolumeInformation( RootDirectory,						volumeName, sizeof(volumeName)/2,						&serialNumber, &maxComponent, &flags,						fileSystem, sizeof(fileSystem)/2)) {//.........这里部分代码省略.........
开发者ID:HBelusca,项目名称:NasuTek-Odyssey,代码行数:101,


示例28: GetBasicFlags

//=============================================================================// Function: GetBasicFlags// Purpose: Set basic flags, primarily wxFS_VOL_REMOTE and wxFS_VOL_REMOVABLE.// Notes: - Local and mapped drives are mounted by definition.  We have no//          way to determine mounted status of network drives, so assume that//          all drives are mounted, and let the caller decide otherwise.//        - Other flags are 'best guess' from type of drive.  The system will//          not report the file attributes with any degree of accuracy.//=============================================================================static unsigned GetBasicFlags(const wxChar* filename){    unsigned flags = wxFS_VOL_MOUNTED;    //----------------------------------    // 'Best Guess' based on drive type.    //----------------------------------    wxFSVolumeKind type;    switch(GetDriveType(filename))    {    case DRIVE_FIXED:        type = wxFS_VOL_DISK;        break;    case DRIVE_REMOVABLE:        flags |= wxFS_VOL_REMOVABLE;        type = wxFS_VOL_FLOPPY;        break;    case DRIVE_CDROM:        flags |= wxFS_VOL_REMOVABLE | wxFS_VOL_READONLY;        type = wxFS_VOL_CDROM;        break;    case DRIVE_REMOTE:        flags |= wxFS_VOL_REMOTE;        type = wxFS_VOL_NETWORK;        break;    case DRIVE_NO_ROOT_DIR:        flags &= ~wxFS_VOL_MOUNTED;        type = wxFS_VOL_OTHER;        break;    default:        type = wxFS_VOL_OTHER;        break;    }    //-----------------------------------------------------------------------    // The following most likely will not modify anything not set above,    // and will not work at all for network shares or empty CD ROM drives.    // But it is a good check if the Win API ever gets better about reporting    // this information.    //-----------------------------------------------------------------------    SHFILEINFO fi;    long rc = SHGetFileInfo(filename, 0, &fi, sizeof(fi), SHGFI_ATTRIBUTES);    if (!rc)    {        // this error is not fatal, so don't show a message to the user about        // it, otherwise it would appear every time a generic directory picker        // dialog is used and there is a connected network drive        wxLogLastError(wxT("SHGetFileInfo"));    }    else    {        if (fi.dwAttributes & SFGAO_READONLY)            flags |= wxFS_VOL_READONLY;        if (fi.dwAttributes & SFGAO_REMOVABLE)            flags |= wxFS_VOL_REMOVABLE;    }    //------------------    // Flags are cached.    //------------------    s_fileInfo[filename] = FileInfo(flags, type);    return flags;} // GetBasicFlags
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:78,



注:本文中的GetDriveType函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ GetDriveTypeA函数代码示例
C++ GetDownscaledMapDifficultyData函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。