#include <stdio.h> #include <stdlib.h> #include <Windows.h> #pragma comment(lib, "User32.lib") #define MAX_PATH 1000 #define TAILLE_MAX 1000 int main(int argc, char *argv[]) { char Entree[TAILLE_MAX] = ""; char ExePath[MAX_PATH] = ""; GetModuleFileName(0, ExePath, MAX_PATH); lstrcpy(strrchr(ExePath, '\\')+1,"Test.ini"); GetPrivateProfileString("TEST", "Entry", "Error...", Entree, sizeof(Entree), ExePath); printf("%s\n", Entree); system("Pause"); }
DWORD attrib = GetFileAttributes(ExePath);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question#include <stdio.h> #include <stdlib.h> #include <Windows.h> #pragma comment(lib, "User32.lib") #define MAX_PATH 1000 #define TAILLE_MAX 1000 int main(int argc, char *argv[]) { FILE* Source = NULL; FILE* Resultat = NULL; char hexadecimal[3] = ""; long resultat = 0; char Entree[TAILLE_MAX] = ""; char ExePath[MAX_PATH] = ""; DWORD attrib = 0; GetModuleFileName(0, ExePath, MAX_PATH); lstrcpy(strrchr(ExePath, '\\')+1,"Test.ini"); attrib = GetFileAttributes(ExePath); printf("%s\n", ExePath); printf("%d\n", attrib); if(attrib == INVALID_FILE_ATTRIBUTES) { printf("Erreur localisation fichier Test.ini\n"); system("Pause"); exit(EXIT_FAILURE); } GetPrivateProfileString("TEST", "Entry", "Error...", Entree, sizeof(Entree), ExePath); printf("%s\n", Entree); system("Pause"); exit(EXIT_SUCCESS); }