Extraction d’informations de fichier à partir du fichier INF

Une fois le fichier INF ouvert, vous pouvez recueillir des informations à partir de celui-ci pour créer l’interface utilisateur ou pour diriger le processus d’installation. Les fonctions d’installation offrent plusieurs niveaux de fonctionnalités pour collecter des informations à partir d’un fichier INF.

Pour collecter des informations... Utilisez ces fonctions...
À propos du fichier INF SetupGetInfInformation
SetupQueryInfFileInformation
SetupQueryInfVersionInformation.
À propos des fichiers source et cible SetupGetSourceFileLocation
SetupGetSourceFileSize
SetupGetTargetPath
SetupGetSourceInfo
À partir d’une ligne d’un fichier INF SetupGetLineText
SetupFindNextLine
SetupFindNextMatchLine
SetupGetLineByIndex
SetupFindFirstLine
À partir d’un champ d’une ligne dans un fichier INF SetupGetStringField
SetupGetIntField
SetupGetBinaryField
SetupGetMultiSzField

L’exemple suivant utilise la fonction SetupGetSourceInfo pour récupérer la description explicite d’un média source à partir d’un fichier INF.

#include <windows.h>
#include <setupapi.h>

BOOL test;  
HINF MyInf;
UINT SourceId;
PTSTR Buffer;
DWORD MaxBufSize;
DWORD BufSize;

int main()  
{ 

test = SetupGetSourceInfo (
     MyInf,   //Handle to the INF file to access                
     SourceId, //Id of the source media                 
     SRCINFO_DESCRIPTION, //which information to retrieve     
     Buffer, //a pointer to the buffer to receive the information                     
     MaxBufSize,  //the size allocated for the buffer 
     &BufSize    //buffer size actually needed
);
  
return 0;
}

Dans l’exemple, MyInf est le descripteur du fichier INF ouvert. SourceId est l’identificateur d’un média source spécifique. La valeur SRCINFO _ Description spécifie que la fonction SetupGetSourceInfo doit récupérer la description du média source. La mémoire tampon pointe vers une chaîne qui reçoit la description, MaxBufSize indique les ressources allouées à la mémoire tampon, et BufSize indique les ressources nécessaires pour stocker la mémoire tampon.

Si BufSize est supérieur à MaxBufSize, la fonction retourne false et un appel suivant à GETLASTERROR retourne l’erreur _ mémoire tampon insuffisante _ .