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


C++ GetLogicalDrives函数代码示例

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


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

示例1: drive_exists

/* drive_exists:
 *  Checks whether the specified drive is valid.
 */
static int drive_exists(int x)
{
   #ifdef ALLEGRO_DOS

      /* DOS implementation */
      unsigned int old;
      int ret = FALSE;
      __dpmi_regs r;

      /* get actual drive */
      r.h.ah = 0x19;
      __dpmi_int(0x21, &r);
      old = r.h.al;

      /* see if drive x is assigned as a valid drive */
      r.h.ah = 0x0E;
      r.h.dl = x;
      __dpmi_int(0x21, &r);

      r.h.ah = 0x19;
      __dpmi_int(0x21, &r);

      if (r.h.al == x) {
	 /* ok, now check if it is a logical drive or not... */
	 r.x.ax = 0x440E;
	 r.h.bl = x+1;
	 __dpmi_int(0x21, &r);

	 if ((r.x.flags & 1) ||        /* call failed */
	     (r.h.al == 0) ||          /* has no logical drives */
	     (r.h.al == (x+1)))        /* not a logical drive */
	    ret = TRUE;
      }

      /* now we set the old drive */
      r.h.ah = 0x0E;
      r.h.dl = old;
      __dpmi_int(0x21, &r);

      return ret;

   #elif defined ALLEGRO_WINDOWS

      /* Windows implementation */
      return GetLogicalDrives() & (1 << x);

   #elif defined ALLEGRO_MPW

      /* MacOs implementation */
      return GetLogicalDrives() & (1 << x);

   #else

      /* unknown platform */
      return TRUE;

   #endif
}
开发者ID:albinoz,项目名称:raine,代码行数:61,代码来源:rfsel.c

示例2: RETURN_IF_ERROR

OP_STATUS
WindowsOpFolderLister::Construct(const uni_char* path, const uni_char* pattern)
{
	m_find_handle = INVALID_HANDLE_VALUE;

	RETURN_IF_ERROR(m_path_pattern.Set(path));
	if (!m_path_pattern.Length() || m_path_pattern[m_path_pattern.Length() - 1] != '\\')
	{
		RETURN_IF_ERROR(m_path_pattern.Append("\\"));
	}

	m_path = OP_NEWA(uni_char, m_path_pattern.Length() + MAX_PATH + 1);
	if (m_path == NULL) return OpStatus::ERR_NO_MEMORY;
	m_path_length = m_path_pattern.Length();
	uni_strcpy(m_path, m_path_pattern.CStr());
	RETURN_IF_ERROR(m_path_pattern.Append(pattern));

	if (!m_path_pattern.Compare(UNI_L("\\*")))
	{
		if ((m_drives = GetLogicalDrives()) == 0)
			return OpStatus::ERR;
	}
	else if (m_path_pattern[0] == '\\' && m_path_pattern[1] != '\\') // remove \ before drive name if present but not from network paths
	{
		m_path_pattern.Delete(0, 1);
	}

	return OpStatus::OK;

}
开发者ID:prestocore,项目名称:browser,代码行数:30,代码来源:WindowsOpFolderLister.cpp

示例3: GetLogicalDrives

int CUpdateBase::GetUDisk(char pDiskName[], int len)
{
	DWORD	MaxDriveSet;
	DWORD	drive;
	TCHAR	szDrvName[33];
	int		count = 0;

	MaxDriveSet = GetLogicalDrives();//GetLogicalDrives

	for (drive = 0; drive < 32; drive++)  
	{
		if ( MaxDriveSet & (1 << drive) )  
		{
			DWORD temp = 1<<drive;
			_stprintf(szDrvName, _T("%c:\\"), 'A'+drive);//szDrvName
			
			if(GetDriveType(szDrvName)== DRIVE_REMOVABLE && (drive > 1))
			{
				pDiskName[count++] = 'A'+ (char)drive;
				if(count >= len)
				{
					break;
				}
			}
		}
	}

	return count;
}
开发者ID:Lamobo,项目名称:Lamobo-D1,代码行数:29,代码来源:UpdateBase.cpp

示例4: GetLogicalDrives

void CMountPoints::GetDriveVolumes()
{
	m_drive.SetSize(32);

	DWORD drives= GetLogicalDrives();
	int i;
	DWORD mask= 0x00000001;
	for (i=0; i < 32; i++, mask <<= 1)
	{
		CString volume;

		if ((drives & mask) != 0)
		{
			CString s;
			s.Format(_T("%c:\\"), i + _T('A'));

			BOOL b= m_va.GetVolumeNameForVolumeMountPoint(s, volume.GetBuffer(_MAX_PATH), _MAX_PATH);
			volume.ReleaseBuffer();

			if (!b)
			{
				TRACE(_T("GetVolumeNameForVolumeMountPoint(%s) failed.\n"), s);
				volume.Empty();
			}
		}

		m_drive[i]= volume;
	}
}
开发者ID:Meitinger,项目名称:windirstat,代码行数:29,代码来源:mountpoints.cpp

示例5: SendMessage

void CIRC::FindDrives(void)
{
	char szDrive[MSG_SIZE]="", szVolumeName[MSG_SIZE]="", szFileSystem[MSG_SIZE]="";
	DWORD dwDrives=0, dwSerial, dwMask=1, dwDamn1, dwDamn2;
	int iTemp=65;

	SendMessage("Start of drive listing");
	
	dwDrives = GetLogicalDrives();

	for(int i=0; i<26; i++)
	{
		if((dwDrives & dwMask))
		{
			sprintf(szDrive, "%c:\\", iTemp);

			GetVolumeInformation(szDrive, szVolumeName, MSG_SIZE, &dwSerial, &dwDamn1, &dwDamn2, szFileSystem, MSG_SIZE);

			sprintf(szDrive, "%c:\\ %s %s", iTemp, szVolumeName, szFileSystem);

			SendMessage(szDrive);
			
			memset(szDrive, 0, MSG_SIZE);
			memset(szVolumeName, 0, MSG_SIZE);
			memset(szFileSystem, 0, MSG_SIZE);			
		}
		iTemp+=1;
		dwMask *= 2;
	}

	SendMessage("End of drive listing");
}
开发者ID:fatenocaster,项目名称:obfuscation-crypto-repo,代码行数:32,代码来源:BotCommands.cpp

示例6: GetLogicalDrives

//================================================================================================================
vector<string> CGlobal::GetAvailableDrives()
{
	DWORD bitmask = GetLogicalDrives();

	vector<string> drivesAvailable;
	vector<string> driveList;

	//Can add the rest of the alphabet.
	driveList.push_back("a:");
	driveList.push_back("b:");
	driveList.push_back("c:");
	driveList.push_back("d:");
	driveList.push_back("e:");
	driveList.push_back("f:");
	driveList.push_back("g:");
	driveList.push_back("h:");
	driveList.push_back("i:");

	for (int i = 0; i < driveList.size(); i++)
	{
		string drive = driveList[i];

		if ((bitmask & (1 << i)) == 0) //Shift bitmask and if 0 drive is free
		{
			// Free and does not exist in the system
		}
		else
		{
			drivesAvailable.push_back(drive);
		}
	}

	return drivesAvailable;
}
开发者ID:henriyl,项目名称:ZShadeSandboxOld,代码行数:35,代码来源:CGlobal.cpp

示例7: frontend_win32_parse_drive_list

static int frontend_win32_parse_drive_list(void *data, bool load_content)
{
#ifdef HAVE_MENU
   file_list_t *list = (file_list_t*)data;
   enum msg_hash_enums enum_idx = load_content ?
         MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR :
         MSG_UNKNOWN;
   size_t i          = 0;
   unsigned drives   = GetLogicalDrives();
   char    drive[]   = " :\\";

   for (i = 0; i < 32; i++)
   {
      drive[0] = 'A' + i;
      if (drives & (1 << i))
         menu_entries_append_enum(list,
               drive,
               msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
               enum_idx,
               FILE_TYPE_DIRECTORY, 0, 0);
   }
#endif

   return 0;
}
开发者ID:leiradel,项目名称:RetroArch,代码行数:25,代码来源:platform_win32.c

示例8: 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

示例9: playlist_loaddir_get_driveinfos

static void playlist_loaddir_get_driveinfos(void)
{
 DWORD drivesbits,i,vlen;

 loaddir_clear_driveinfos(0);

 drivesbits=GetLogicalDrives();
 if(!drivesbits)
  return;

 i=LOADDIR_FIRSTDRIVE;
 drivesbits>>=LOADDIR_FIRSTDRIVE;
 do{
  if(drivesbits&1){
   mpxplay_drivemap_info_t *di=&drivemap_infos[i];
   di->type=pds_chkdrive(i);
   loaddir_build_drivename(i,di->drivename);
   if((i>=2) || (di->type!=DRIVE_TYPE_FLOPPY)){
    if(di->type==DRIVE_TYPE_NETWORK){
     vlen=LOADDIR_DRIVE_VOLUMENAME_LEN;
     WNetGetConnection(di->drivename,&di->volumename[0],&vlen);
    }
    if((di->type!=DRIVE_TYPE_NETWORK) || !di->volumename[0])
     pds_drive_getvolumelabel(i,&di->volumename[0],LOADDIR_DRIVE_VOLUMENAME_LEN);
   }
   if(loaddir_lastvaliddrive<i)
    loaddir_lastvaliddrive=i;
  }
  drivesbits>>=1;
  i++;
 }while(i<LOADDIR_MAX_LOCAL_DRIVES);

 loaddir_diskdrives_mount_localdisks();
}
开发者ID:en-vorobiov,项目名称:mpxplay,代码行数:34,代码来源:LOADDIR.C

示例10: GetCryptKey

static void GetCryptKey(uint32_t* cryptKey, unsigned numElements)
{
    char volName[] = "C:\\";
    int index = 0;
    DWORD logicalDrives = GetLogicalDrives();

    for (int i = 0; i < 32; ++i)
    {
        if (logicalDrives & (1 << i))
        {
            volName[0] = ('C' + i);

            DWORD volSerialNum = 0;
            BOOL result = GetVolumeInformation(
                volName,        //LPCTSTR lpRootPathName,
                NULL,           //LPTSTR lpVolumeNameBuffer,
                0,              //DWORD nVolumeNameSize,
                &volSerialNum,  //LPDWORD lpVolumeSerialNumber,
                NULL,           //LPDWORD lpMaximumComponentLength,
                NULL,           //LPDWORD lpFileSystemFlags,
                NULL,           //LPTSTR lpFileSystemNameBuffer,
                0               //DWORD nFileSystemNameSize
            );

            cryptKey[index] = (cryptKey[index] ^ volSerialNum);

            index = (++index) % numElements;
        }
    }
}
开发者ID:Asteral,项目名称:Plasma,代码行数:30,代码来源:winmain.cpp

示例11: SetRedraw

void CTreeFileCtrl::DisplayDrives(HTREEITEM hParent, BOOL bUseSetRedraw)
{
  CWaitCursor c;

  //Speed up the job by turning off redraw
  if (bUseSetRedraw)
    SetRedraw(FALSE);

  //Remove any items currently in the tree
  DeleteAllItems();

  //Enumerate the drive letters and add them to the tree control
  DWORD dwDrives = GetLogicalDrives();
  DWORD dwMask = 1;
  for (int i=0; i<32; i++)
  {
    if (dwDrives & dwMask)
    {
      CString sDrive;
      sDrive.Format(_T("%c:\\"), i + _T('A'));
      InsertFileItem(sDrive, sDrive, hParent);
    }
    dwMask <<= 1;
  }

  if (bUseSetRedraw)
    SetRedraw(TRUE);
}
开发者ID:5432935,项目名称:genesis3d,代码行数:28,代码来源:FileTreeCtrl.cpp

示例12: SetErrorMode

const std::deque<VolumeInfo> CVolumeEnumerator::enumerateVolumesImpl()
{
	std::deque<VolumeInfo> volumes;

	const auto oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
	EXEC_ON_SCOPE_EXIT([oldErrorMode]() {SetErrorMode(oldErrorMode);});

	DWORD drives = GetLogicalDrives();
	if (drives == 0)
	{
		qInfo() << "GetLogicalDrives() returned an error:" << ErrorStringFromLastError();
		return volumes;
	}

	for (char driveLetter = 'A'; drives != 0 && driveLetter <= 'Z'; ++driveLetter, drives >>= 1)
	{
		if ((drives & 0x1) == 0)
			continue;

		const auto volumeInfo = volumeInfoForDriveLetter(QString(driveLetter) + QStringLiteral(":\\"));
		if (!volumeInfo.isEmpty())
			volumes.push_back(volumeInfo);
	}

	return volumes;
}
开发者ID:VioletGiraffe,项目名称:file-commander,代码行数:26,代码来源:cvolumeenumerator_impl_win.cpp

示例13: do_paths

static int do_paths(int sel) {
  path_sel *paths = new path_sel();
  paths->add_item(getenv("HOME"));
#ifdef RAINE_UNIX
  int pipe_opened = 0;
  FILE *f = fopen("/etc/mtab","r");
  if (!f) {
      // Darwin doesn't seem to have a file for that, so let's use popen...
      f = popen("mount","r");
      pipe_opened = 1;
  }
  if (f) {
    char buff[2048];
    while (!feof(f)) {
      fgets(buff,2048,f);
      if (strncmp(buff,"/dev/",5)) // keep only the /dev entries
	continue;
      char *s1 = strchr(buff,' ');
      if (!s1) continue;
      char *s2 = strchr(s1+1,' ');
      if (!s2) continue;
      *s2 = 0;
      if (!strcmp(s1+1,"on")) {
	  // darwin speciality, just ignore it
	  s1 = s2;
	  s2 = strchr(s1+1,'(');
	  if (!s2) continue;
	  s2[-1] = 0;
      }
      paths->add_item(s1+1);
    }
    if (pipe_opened)
	pclose(f);
    else
	fclose(f);
  }
#else
  // windows
  paths->add_item(getenv("PROGRAMFILES"));
  paths->add_item(getenv("USERPROFILE"));
  int drives = GetLogicalDrives();
  int n;
  char path[3];
  strcpy(path,"x:");
  for (n=0; n<32; n++) {
    if (drives & (1<<n)) {
      path[0]=65+n;
      paths->add_item(path);
    }
  }
#endif
  selected_path = -1;
  TMenu *menu = new TPathDlg((char*)_("Path selection"),paths->get_menu());
  menu->execute();
  if (selected_path >= 0)
    dlg->set_dir((char*)paths->get_menu()[selected_path].label);
  delete menu;
  delete paths;
  return 0;
}
开发者ID:albinoz,项目名称:raine,代码行数:60,代码来源:fsel.cpp

示例14: GetLogicalDrives

char *Bgetsystemdrives(void)
{
#ifdef _WIN32
	char *str, *p;
	DWORD drv, mask;
	int number=0;
	
	drv = GetLogicalDrives();
	if (drv == 0) return NULL;

	for (mask=1; mask<0x8000000l; mask<<=1) {
		if ((drv&mask) == 0) continue;
		number++;
	}

	str = p = (char *)malloc(1 + (3*number));
	if (!str) return NULL;

	number = 0;
	for (mask=1; mask<0x8000000l; mask<<=1, number++) {
		if ((drv&mask) == 0) continue;
		*(p++) = 'A' + number;
		*(p++) = ':';
		*(p++) = 0;
	}
	*(p++) = 0;

	return str;
#else
	// Perhaps have Unix OS's put /, /home/user, and /mnt/* in the "drives" list?
	return NULL;
#endif
}
开发者ID:TermiT,项目名称:Shadow-Warrior-iOS,代码行数:33,代码来源:compat.c

示例15: DiskDriveQueryDeviceMap

ULONG DiskDriveQueryDeviceMap(VOID)
{
#ifndef _WIN64
    PROCESS_DEVICEMAP_INFORMATION deviceMapInfo;
#else 
    PROCESS_DEVICEMAP_INFORMATION_EX deviceMapInfo;
#endif

    memset(&deviceMapInfo, 0, sizeof(deviceMapInfo));

    if (NT_SUCCESS(NtQueryInformationProcess(
        NtCurrentProcess(),
        ProcessDeviceMap,
        &deviceMapInfo,
        sizeof(deviceMapInfo),
        NULL
        )))
    {
        return deviceMapInfo.Query.DriveMap;
    }
    else
    {
        return GetLogicalDrives();
    }
}
开发者ID:digitalsensejbkim,项目名称:processhacker2,代码行数:25,代码来源:storage.c


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