Dll Probleme mit File Pointern
-
Ich habe mit DLL´s folgendes Problem mit File Pointern.
Die in einem Programm einwandfrei funktionierende Funktion, wollte ich mit anderen Toolfunktionen in eine DLL auslagern, was bis auf diese Funktion auch erfolgreich war.
Sobald ich diese Funktion in die DLL ausgelagert habe und sie aus einem Programm mit korrekt geöffnetem Filepointer aus aufrufe stürzt mir das Programm mit einem Memory Access fault ab und zwar beim ersten fprintf.
Erzeuge ich anstelle der DLL eine statische lib oder kopiere ich die Funktion zum Projekt funktioniert sie einwandfrei.Hat irgendjemand eine Idee.
INT32 _ETZ_FUNCS WrFHead(FILE *fp, SysVersion *VersRec, char *s, char *id,int zflag,char *trailer) { FILE *fpcmt; char line[81]; char *ptr; char tmpbuf[128]; /* Set time zone from TZ environment variable. If TZ is not set, * the operating system is queried to obtain the default value * for the variable. */ GetTimeDate(tmpbuf); fprintf(fp,"%s Start:%s,",trailer,tmpbuf); fprintf(fp,"\r\n%s %s", trailer,SystemVersion(VersRec, LIBCOMMENT1)); fprintf(fp,"\r\n%s P/N : %s ", trailer,SystemVersion(VersRec, LIBPARTNUM)); fprintf(fp,"\r\n%s REV.: %s",trailer, SystemVersion(VersRec, LIBVERSION)); fprintf(fp,"\r\n%s ID: %s\r\n",trailer,id); if(strlen(s) ) { fprintf(fp,"%s Comment : ",trailer); if( (ptr = strstr(s,"F:")) != NULL ) { strcpy(line, ptr+2); if( (fpcmt = fopen(line,"rt") ) != NULL ) { fprintf(fp,"\r\n"); do { if( fgets(line,81, fpcmt) != NULL ) fprintf(fp,"%s %s\r\n",trailer,line); } while( !feof(fpcmt) ); fclose(fpcmt); } } else fprintf(fp,"%s\r\n",s); } else fprintf(fp,"%sComment :\r\n",trailer); if(zflag) fprintf(fp,"\x1a"); // CTRL-Z return 0; }
Danke
-
wie lädst du die dll denn?
-
sie wird bei programmstart implizit geladen, d.h. das zugehörige libfile ist im Projekt eingebunden.