当前位置: 首页>>代码示例>>C++>>正文


C++ GetLogicalDriveStrings函数代码示例

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


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

示例1: MyGetLogicalDriveStrings

bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings)
{
  driveStrings.Clear();
  UINT32 size = GetLogicalDriveStrings(0, NULL);
  if (size == 0)
    return false;
  CSysString buffer;
  UINT32 newSize = GetLogicalDriveStrings(size, buffer.GetBuffer(size));
  if (newSize == 0)
    return false;
  if (newSize > size)
    return false;
  CSysString string;
  for (UINT32 i = 0; i < newSize; i++)
  {
    TCHAR c = buffer[i];
    if (c == TEXT('\0'))
    {
      driveStrings.Add(string);
      string.Empty();
    }
    else
      string += c;
  }
  if (!string.IsEmpty())
    return false;
  return true;
}
开发者ID:119,项目名称:aircam-openwrt,代码行数:28,代码来源:FileFind.cpp

示例2: GetLogicalDriveStrings

void sloDiskManager::FindAllDrivers()
{
	DWORD dwNumBytesForDriveStrings;//实际存储驱动器号的字符串长度
	HANDLE hHeap;
	LPSTR lp;
	CString strLogdrive;
	
	//获得实际存储驱动器号的字符串长度
	dwNumBytesForDriveStrings=GetLogicalDriveStrings(0,NULL)*sizeof(TCHAR);
	
	//如果字符串不为空,则表示有正常的驱动器存在
	if (dwNumBytesForDriveStrings!=0) {
		//分配字符串空间
		hHeap=GetProcessHeap();
		lp=(LPSTR)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,
			dwNumBytesForDriveStrings);
		
		//获得标明所有驱动器的字符串
		GetLogicalDriveStrings(HeapSize(hHeap,0,lp),lp);
		
		//将驱动器一个个放到下拉框中
		while (*lp!=0) {
			//Driver->AddString(lp);
			GetDrvSpaceInfo(lp);
			
			lp=_tcschr(lp,0)+1;
		}
	}
	
}
开发者ID:MrMattMunro,项目名称:filesearch,代码行数:30,代码来源:sloDiskManager.cpp

示例3: sync_win32

static int
sync_win32 (void)
{
  DWORD n1, n2;

  n1 = GetLogicalDriveStrings (0, NULL);
  if (n1 == 0)
    return -1;

  TCHAR buffer[n1+2]; /* sic */
  n2 = GetLogicalDriveStrings (n1, buffer);
  if (n2 == 0)
    return -1;

  TCHAR *p = buffer;

  /* The MSDN example code itself assumes that there is always one
   * drive in the system.  However we will be better than that and not
   * make the assumption ...
   */
  while (*p) {
    HANDLE drive;
    DWORD drive_type;

    /* Ignore removable drives. */
    drive_type = GetDriveType (p);
    if (drive_type == DRIVE_FIXED) {
      /* To open the volume you have to specify the volume name, not
       * the mount point.  MSDN documents use of the constant 50
       * below.
       */
      TCHAR volname[50];
      if (!GetVolumeNameForVolumeMountPoint (p, volname, 50))
        return -1;

      drive = CreateFile (volname, GENERIC_READ|GENERIC_WRITE,
                          FILE_SHARE_READ|FILE_SHARE_WRITE,
                          NULL, OPEN_EXISTING, 0, 0);
      if (drive == INVALID_HANDLE_VALUE)
        return -1;

      BOOL r;
      /* This always fails in Wine:
       * http://bugs.winehq.org/show_bug.cgi?id=14915
       */
      r = FlushFileBuffers (drive);
      CloseHandle (drive);
      if (!r)
        return -1;
    }

    /* Skip to next \0 character. */
    while (*p++);
  }

  return 0;
}
开发者ID:FengYang,项目名称:libguestfs,代码行数:57,代码来源:sync.c

示例4: getrootdirs

/* get the list of root directories on mounted drives */
char * getrootdirs (char * getrootdirs)
{
     DWORD dw;

     dw = GetLogicalDriveStrings (0, NULL);
//  fprintf(stderr, "GetLogicalDriveStrings: %d\n", dw);
     getrootdirs = HeapAlloc (GetProcessHeap(), 0, dw * sizeof(TCHAR));
     GetLogicalDriveStrings (dw, getrootdirs);
//  fprintf(stderr, "getrootdirs: %s\n", getrootdirs);
     return(getrootdirs);
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:12,代码来源:mntent_r.c

示例5: GetDriveList

LONG GetDriveList(drv_list_t& drvList)
{
	DWORD dwLen = GetLogicalDriveStrings(0, 0);
	TCHAR* tszDriveList = new TCHAR[dwLen + 1];
    dwLen = GetLogicalDriveStrings(dwLen, tszDriveList);

    LONG lRet = ParseDriveString(drvList, tszDriveList);
	delete[] tszDriveList;

	return lRet;
}
开发者ID:runsisi,项目名称:Grub4Win,代码行数:11,代码来源:diskinfo.cpp

示例6: GetLogicalDriveStrings

/*
 *******************************************************************
 * Function: bool GetLogicalDrives() 
 *
 * Description : Will fill the virtools aray (from the P-In) 
 *		with a list of the logical drives
 *		
 * Paramters :
 *    CKBehavior* r The virtool behaviour
 *
 * Returns : True if it succeeds, otherwise false
 *
 *******************************************************************
 */
bool CGBLFileSystem::GetLogicalDrives(CKBehavior* beh)
{
	// scan for a list of all the logical drives "a:\ b:\ c:\"
	char      *allDriveStrings = NULL;
	// get the length of the string to be returned
	size_t lAllDriveStrings = GetLogicalDriveStrings( 0, NULL );
	
	// Get the destination data array and clear it out
	CKDataArray* dataArray = static_cast<CKDataArray*>(beh->GetInputParameterObject(eParamInputDataArray));
	if (!dataArray)
	{
		CGBLWidget::OutputBBErrorMsg(beh, "Please attatch an array to the BB");
		return FALSE;
	}
	dataArray->Clear();

	assert( allDriveStrings == NULL );
	// get the string containing all the logical drives
	allDriveStrings = new char[ lAllDriveStrings + sizeof (EMPTY_STRING) ]; // + for trailer
	if( GetLogicalDriveStrings( lAllDriveStrings, allDriveStrings ) != lAllDriveStrings - 1 )
	{
		CGBLWidget::OutputBBErrorMsg(beh, "Failed to get logical drive strings");
		return FALSE;
	}
	else
	{
		assert( allDriveStrings != NULL );
		char* driveString = allDriveStrings;
		size_t lDriveString = strlen( driveString );
		char valueToAdd[BUFSIZE]={'\0'};

		// loop through all the logical drives, tyring to get a display name
		while( lDriveString > 0 )
		{		
			strcpy(valueToAdd,driveString);
		
			dataArray->AddRow();
			int currentRow = dataArray->GetRowCount()-1; // 0 index
			dataArray->SetElementStringValue(currentRow,NAME_COLUMN,valueToAdd);

			driveString += lDriveString + 1;
			lDriveString = strlen( driveString );
		}
		// cleanup
		if (allDriveStrings)
		{
			delete allDriveStrings;
			allDriveStrings = NULL;
		}
	}
	return TRUE;
}
开发者ID:gbaumgart,项目名称:GBL_Backup,代码行数:66,代码来源:GBLFileSystem.cpp

示例7: memset

bool IdentClient::SendParaSysStorage()
{
	bool bRet = false;
	if (m_IsSvrConnected)
	{
		memset(&m_cmdTransfer,0x00,sizeof(m_cmdTransfer));
		size_t szAllDriveStrings = GetLogicalDriveStrings(0,NULL);
		char *pDriveStrings = new char[szAllDriveStrings + sizeof((""))];
		GetLogicalDriveStrings(szAllDriveStrings,pDriveStrings);
		size_t szDriveString = strlen(pDriveStrings);
		int iMaxnumDrive = sizeof(g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc)/sizeof(g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[0]);
		int DriveIndex = 0;
		for(DriveIndex = 0; DriveIndex < iMaxnumDrive && szDriveString > 0; DriveIndex++)
		{
			strcpy((char *)g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].disk_name,pDriveStrings);
			unsigned long long FreeAv,TotalBytes,FreeBytes;
			if (GetDiskFreeSpaceEx(pDriveStrings,&FreeAv,&TotalBytes,&FreeBytes))
			{
				g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].realsize = TotalBytes.QuadPart/(unsigned long long)(1024*1024);
				g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].emptysize = FreeAv.QuadPart/(unsigned long long)(1024*1024);
			}
			g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_type = (DRIVE_TYPE)GetDriveType(pDriveStrings);
			char drive_fs_type[128];
			if(!GetVolumeInformation(pDriveStrings,NULL,0,NULL,NULL,NULL,drive_fs_type,128))
			{
				g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_UNKNOWN;
			}
			else
			{
				if(!strcmp(drive_fs_type,"NTFS"))
				{
					g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_NTFS;
				}
				else if(!strcmp(drive_fs_type,"FAT32"))
				{
					g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_FAT32;
				}
				else
				{
					g_stGlobal_Flash.sysstoragepara.storageconfig.diskdesc[DriveIndex].drive_fstype = DRIVE_FS_TYPE_UNKNOWN;
				}
			}
			pDriveStrings += szDriveString + 1;
			szDriveString = strlen(pDriveStrings);
		}
		g_stGlobal_Flash.sysstoragepara.storageconfig.diskcount = DriveIndex;
		bRet = CONSTRUCT_CMD(CMD_NUM_SYS_STORAGE_RESPONSE,(char *)&g_stGlobal_Variable.globalflash.sysstoragepara,sizeof(SYS_STORAGE_PARA),&m_cmdTransfer);
		bRet &= SendParaMsg();
	}
	return bRet;
}
开发者ID:NearZhxiAo,项目名称:3730,代码行数:51,代码来源:IdentClient.cpp

示例8: DeleteAllItems

BOOL CDirTreeCtrl::DisplayDrives()
{
	//
	// Displaying the Availible Drives on this PC
	// This are the First Items in the TreeCtrl
	//
	DeleteAllItems();
	char  szDrives[128];
	char* pDrive;

	if ( !GetLogicalDriveStrings( sizeof(szDrives), szDrives ) )
	{
		m_strError = "Error Getting Logical DriveStrings!";
		return FALSE;
	}

	pDrive = szDrives;
	while( *pDrive )
	{
		if (!m_bFixedOnly || GetDriveType(pDrive) == DRIVE_FIXED)
		{
			*pDrive = toupper(*pDrive);
			HTREEITEM hParent = AddItem( TVI_ROOT, pDrive );
			if ( FindSubDir( pDrive ) )
				InsertItem( "", 0, 0, hParent );
		}
		pDrive += strlen( pDrive ) + 1;
	}

	return TRUE;

}
开发者ID:devurandom,项目名称:shadowkeeper,代码行数:32,代码来源:DirTreeCtrl.cpp

示例9: GetOpticalDriveList

static std::vector<std::wstring> GetOpticalDriveList()
{
    DWORD size = GetLogicalDriveStrings(0, nullptr);
    std::vector<wchar_t> drive_strings(size);
    if (GetLogicalDriveStrings(size, drive_strings.data()) != size - 1)
        return {};

    std::vector<std::wstring> drives;
    for (auto p = drive_strings.data(); *p; ++p) {
        if (GetDriveType(p) == DRIVE_CDROM)
            drives.push_back(p);
        while (*p)
            ++p;
    }
    return drives;
}
开发者ID:willkuer,项目名称:pcsx2,代码行数:16,代码来源:config.cpp

示例10: GetComputerDrives

BOOL GetComputerDrives(std::vector<CString>& vecDrive)
{
    BOOL bRet = FALSE;
    CString strDriverName;
    vecDrive.clear();

    TCHAR   szDriverName[500]; 

    DWORD nLength = GetLogicalDriveStrings(sizeof(szDriverName), szDriverName); 

    for (int i = 0; i < (int)nLength; i++) 
    { 
        if (szDriverName[i] != L'\0')
        {
            strDriverName += szDriverName[i]; 
        }
        else 
        { 
            strDriverName = strDriverName.Left(strDriverName.GetLength() - 1); 
            vecDrive.push_back(strDriverName); 
            strDriverName = ""; 
        } 
    }

    if (vecDrive.size() > 0)
        bRet = TRUE;

    return bRet;
}
开发者ID:6520874,项目名称:pcmanager,代码行数:29,代码来源:kcheckinstalled.cpp

示例11: get_disk_info_all

void get_disk_info_all(){
    DWORD dwNumBytesForDriveStrings;
    char DriveStrings[255];
    char* dp = DriveStrings;
    
    dwNumBytesForDriveStrings = GetLogicalDriveStrings(254,dp);
    if (dwNumBytesForDriveStrings != 0) {
	/* GetLogicalDriveStringsIs supported on this platform */
	while (*dp != 0) {
	    output_drive_info(dp);
	    dp = strchr(dp,0) +1;
	}
    }
    else {
	/* GetLogicalDriveStrings is not supported (some old W95) */
	DWORD dwDriveMask = GetLogicalDrives();
	int nDriveNum;
	char drivename[]="A:\\";
	/*printf("DriveName95 DriveType BytesAvail BytesTotal BytesTotalFree\n");*/
	for (nDriveNum = 0; dwDriveMask != 0;nDriveNum++) {
	    if (dwDriveMask & 1) {
		drivename[0]='A'+ nDriveNum;
		output_drive_info(drivename);
	    }
	    dwDriveMask = dwDriveMask >> 1;
	}
    }
}
开发者ID:0x00evil,项目名称:otp,代码行数:28,代码来源:win32sysinfo.c

示例12: DeleteAllItems

BOOL CDirTreeCtrl::DisplayDrives()
{
	DeleteAllItems();
	TCHAR  szDrives[260];
	TCHAR* pDrive=NULL;
	if ( !GetLogicalDriveStrings( sizeof(szDrives), szDrives ) )
		{          m_strError =_T("驱动信息获取失败!");
	return FALSE;
	} 
	pDrive = szDrives;    //szDrives 中的字符串格式:_T("C:\\0D:\\0D:\\0E:\\0")
	m_hDirTreeRoot = InsertItem(_T("project"));

	int len;
	while( *pDrive!=0 )
	{
		len = _tcslen(pDrive);
		pDrive[len-1] = _T('\0');
		HTREEITEM hParent = AddItem( m_hDirTreeRoot, pDrive );
		if ( FindSubDir( pDrive ))  AddSubDirAsItem(hParent);
		
		pDrive += len + 1;
	}

	Expand( m_hDirTreeRoot, TVE_EXPAND );
	return TRUE;
}
开发者ID:neil-yi,项目名称:ffsource,代码行数:26,代码来源:DirTreeCtrl.cpp

示例13: GetLogicalDriveStrings

/******************************************************************************
*	作用:		在指定父节点下插入系统驱动器节点
******************************************************************************/
void CMainFrame::InsertLogicalDrives(HTREEITEM hParent)
{
    DWORD	szAllDriveStrings = GetLogicalDriveStrings(0,NULL);
    LPWSTR	pDriveStrings = new WCHAR[szAllDriveStrings + sizeof(_T(""))];
    LPWSTR	pDel = pDriveStrings;
    GetLogicalDriveStrings(szAllDriveStrings, pDriveStrings);
    size_t szDriveString = wcslen(pDriveStrings);
    while(szDriveString > 0)
    {
        m_TreeCtrl.InsertItem(pDriveStrings, hParent);
        pDriveStrings += szDriveString + 1;
        szDriveString = wcslen(pDriveStrings);
    }

    SAFE_DELETE_ARRAY (pDel);
}
开发者ID:ptthisdan,项目名称:DIPVC,代码行数:19,代码来源:MainFrm.cpp

示例14: LocalFilesScanList

//----------------------------------------------------------------
BOOL LocalFilesScanList(DWORD iitem, char *ip, PSCANNE_ST config, DWORD cb_id)
{
  char tmp[MAX_PATH], letter[3]=" :\0", msg[MAX_PATH], source[MAX_PATH];
  int i,nblecteurs = GetLogicalDriveStrings(MAX_PATH,tmp);
  DWORD nb_file_check = 0;

  for (i=0;i<nblecteurs && scan_start;i+=4)
  {
    switch(GetDriveType(&tmp[i]))
    {
      /*case DRIVE_UNKNOWN:     break;
      case DRIVE_NO_ROOT_DIR: break;
      case DRIVE_CDROM:break;*/

      case DRIVE_FIXED:
      //case DRIVE_REMOTE:
      //case DRIVE_RAMDISK:
      //case DRIVE_REMOVABLE:
        {
          letter[0] = tmp[i];
          nb_file_check = CheckRecursivFilesList(iitem, letter, cb_id);

          snprintf(source,MAX_PATH,"%s\\%s\\",ip,letter);
          snprintf(msg,MAX_PATH,"%lu files checked",nb_file_check);
          AddMsg(h_main,(char*)"INFORMATION (Files)",source,msg);
        }
      break;
    }
  }
  return TRUE;
}
开发者ID:garfieldchien,项目名称:omnia-projetcs,代码行数:32,代码来源:Files.c

示例15: wxLogTrace

void DirectoryTree::InitTree()
  {
  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("InitTree()"));
  DeleteAllItems();

#ifdef __UNIX
  wxTreeItemId tidRoot = AddChild(wxTreeItemId(), FILE_SYSTEM_ROOT);
#elif _WINDOWS
  wxTreeItemId tidRoot = AddRoot(FILE_SYSTEM_ROOT, 0, 1, NULL);
#endif // OS
	if(!tidRoot.IsOk())
    {
    wxLogDebug(wxT("DirectoryTree::InitTree(): AddRoot() failed."));
    return; 
    }

#ifdef _WINDOWS
  // Enumerate the system volumes
  TCHAR szDrives[0x200];
  DWORD dwTotalLength = GetLogicalDriveStrings(0x200 * sizeof(TCHAR), szDrives);
  DWORD dwOffset = 0;
  while(dwOffset < dwTotalLength)
    {
    TCHAR * szDrive = szDrives + dwOffset;
    wxString sDrive(szDrive);
    AddChild(tidRoot, sDrive);

    DWORD dwLength = wcslen(szDrive);
    dwOffset += dwLength + 1;
    }
#endif // OS
  }
开发者ID:joeyates,项目名称:sherpa,代码行数:32,代码来源:DirectoryTree.cpp


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