Pagina 1 di 4 1 2 3 ... ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 32
  1. #1

    [C] - Cartelle valide...

    Non sapevo come intitolare questo thread...

    Vi spiego meglio quello che vorrei sapere: "Esiste un modo per sapere quali cartelle sono valide in risorse del computer?" Cioè mi spiego meglio...

    Ho 3 Unità collegate: A:\ C:\ D:\
    più un lettore di memory card... con lettere che vanno a partire da F:\ G:\ H:\ I:\

    Come faccio ad accedere direttamente a queste unità valide...?

    Se faccio un ciclo for che va da A:\ a Z:\ faccio uno spreco di computazioni e di tempo quindi...

    Spero in voi...

  2. #2
    Utente di HTML.it L'avatar di andbin
    Registrato dal
    Jan 2006
    residenza
    Italy
    Messaggi
    18,254

    Re: [C] - Cartelle valide...

    Originariamente inviato da Vincent
    Non sapevo come intitolare questo thread...

    Vi spiego meglio quello che vorrei sapere: "Esiste un modo per sapere quali cartelle sono valide in risorse del computer?" Cioè mi spiego meglio...

    Ho 3 Unità collegate: A:\ C:\ D:\
    più un lettore di memory card... con lettere che vanno a partire da F:\ G:\ H:\ I:\

    Come faccio ad accedere direttamente a queste unità valide...?

    Se faccio un ciclo for che va da A:\ a Z:\ faccio uno spreco di computazioni e di tempo quindi...

    Spero in voi...
    GetLogicalDrives() e se ti serve sapere il tipo GetDriveType()
    Andrea, andbin.devSenior Java developerSCJP 5 (91%) • SCWCD 5 (94%)
    Java Versions Cheat Sheet

  3. #3
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,466
    Ma consultare MSDN ... no, eh?

  4. #4
    grazie ma sai come si usano? le msdn sono sempre poco chiare...

  5. #5
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,466
    Originariamente inviato da Vincent
    le msdn sono sempre poco chiare...
    VVoVe:

    :::
    GetLogicalDrives

    The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives.


    DWORD GetLogicalDrives(void);

    Parameters
    This function has no parameters

    Return Value
    If the function succeeds, the return value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.

    If the function fails, the return value is zero. To get extended error information, call GetLastError.
    :::

    Mi sembra chiarissima ...

  6. #6
    perchè mi da questo errore?

    'GetMappedFileName' undeclared (first use this function)

    Codice PHP:
    BOOL GetFileNameFromHandle(HANDLE hFile)
    {
      
    BOOL bSuccess FALSE;
      
    TCHAR pszFilename[MAX_PATH+1];
      
    HANDLE hFileMap;

      
    // Get the file size.
      
    DWORD dwFileSizeHi 0;
      
    DWORD dwFileSizeLo GetFileSize(hFile, &dwFileSizeHi);

      if( 
    dwFileSizeLo == && dwFileSizeHi == )
      {
         
    printf("Cannot map a file with a length of zero.\n");
         return 
    FALSE;
      }

      
    // Create a file mapping object.
      
    hFileMap CreateFileMapping(hFile,
                        
    NULL,
                        
    PAGE_READONLY,
                        
    0,
                        
    MAX_PATH,
                        
    NULL);

      if (
    hFileMap)
      {
        
    // Create a file mapping to get the file name.
        
    voidpMem MapViewOfFile(hFileMapFILE_MAP_READ001);

        if (
    pMem)
        {
          if (
    GetMappedFileName (GetCurrentProcess(),
                                 
    pMem,
                                 
    pszFilename,
                                 
    MAX_PATH))
          {

            
    // Translate path with device name to drive letters.
            
    TCHAR szTemp[BUFSIZE];
            
    szTemp[0] = '\0';

            if (
    GetLogicalDriveStrings(BUFSIZE-1szTemp))
            {
              
    TCHAR szName[MAX_PATH];
              
    TCHAR szDrive[3] = TEXT(" :");
              
    BOOL bFound FALSE;
              
    TCHARszTemp;

              do
              {
                
    // Copy the drive letter to the template string
                
    *szDrive = *p;

                
    // Look up each device name
                
    if (QueryDosDevice(szDriveszNameBUFSIZE))
                {
                  
    UINT uNameLen _tcslen(szName);

                  if (
    uNameLen MAX_PATH)
                  {
                    
    bFound _tcsnicmp(pszFilenameszName,
                        
    uNameLen) == 0;

                    if (
    bFound)
                    {
                      
    // Reconstruct pszFilename using szTempFile
                      // Replace device path with DOS path
                      
    TCHAR szTempFile[MAX_PATH];
                      
    StringCchPrintf(szTempFile,
                                
    MAX_PATH,
                                
    TEXT("%s%s"),
                                
    szDrive,
                                
    pszFilename+uNameLen);
                      
    StringCchCopyN(pszFilenameMAX_PATH+1szTempFile_tcslen(szTempFile));
                    }
                  }
                }

                
    // Go to the next NULL character.
                
    while (*p++);
              } while (!
    bFound && *p); // end of string
            
    }
          }
          
    bSuccess TRUE;
          
    UnmapViewOfFile(pMem);
        }

        
    CloseHandle(hFileMap);
      }
      
    _tprintf(TEXT("File name is %s\n"), pszFilename);
      return(
    bSuccess);


  7. #7
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,466
    Ma cosa c'entra questo con il primo quesito?

  8. #8
    ho la febbre, e si vede... chiedo scusa oregon, ma hai ragione non c'entra nulla!

  9. #9
    Originariamente inviato da Vincent
    ho la febbre, e si vede... chiedo scusa oregon, ma hai ragione non c'entra nulla!
    Utilizzi il Dev-cpp vero ?
    Usa la GetMappedFileNameA (se il tuo programma è ANSI, GetMappedFileNameW se è UNICODE)
    E riguardati
    01010011 01100001 01101101 01110101 01100101 01101100 01100101 01011111 00110111 00110000
    All errors are undocumented features waiting to be discovered.

  10. #10
    ragazzi ho scritto qualche riga...

    codice:
       char pathWithDrive[MAX_PATH] = { 'C',':','\\',0 };
    
       DWORD logicalDrives = GetLogicalDrives();
       int i;
       char driveLetter = 'A';
    
       for(i=0; i<26; i++ )
       {
          if(logicalDrives)
          {
              pathWithDrive[0] = driveLetter + i;
              Cerca_Files (pathWithDrive,Cartella,0);
          }
       }
    ma come faccio ad ignorare i drive che non sono collegati...?

    così mi esegue comunque il controllo per tutti i drive a partire da A:\...
    io voglio che se A:\ non è presente nel sistema, non cerchi proprio e passi a verificare se c'è il drive B:\, e così via per tutti i drives....

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.