Applikationsverzeichnis und Dateiname zusammenfügen
-
Hallo zusammen,
ich möchte aus einer Textdatei den Inhalt auslesen. Leider weiß ich nicht so genau wie ich den Pfad bekomme.
Bisher mache ich das so:
#include <windows.h> #include <stdio.h> #include <string.h> char Line[9]; void GetMyOrientation( void ) { FILE *Ptr; CHAR szAppPath[255]; char FName [255]; char *result; int myPos = 0; GetModuleFileName(NULL,szAppPath,sizeof(szAppPath)); result = strrchr(szAppPath, '/'); myPos = result - szAppPath + 1; if (result != NULL) { strncpy(FName, szAppPath, myPos); lstrcat(FName,"meinedatei.tmp_"); Ptr = fopen(FName, "r"); gets(Line); } fclose(Ptr); }Aber irgendwie bekomme ich bei strrchr eine aufforderung zur Verzeichnisangabe von strrchr.asm.
Danke im Voraus & Gruß,
Moony
-
Habe die Lösung gefunden:
void GetMyOrientation( void ) { FILE *Ptr; char FName [255]; char szAppPath[_MAX_PATH]; char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; char fname[_MAX_FNAME]; char ext[_MAX_EXT]; GetModuleFileName(NULL,szAppPath,sizeof(szAppPath)); _splitpath(szAppPath, drive, dir, fname, ext); lstrcat(FName,drive); lstrcat(FName,dir); lstrcat(FName,"datacard.tmp_"); Ptr = fopen(FName, "r"); gets(Line); fclose(Ptr); }