Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!uupsi!cai.com!dxg From: dxg@cai.com Newsgroups: comp.windows.ms.programmer Subject: HELP! Calling fopen() in DLL Message-ID: <394.28314261@cai.com> Date: 15 May 91 14:14:57 GMT Organization: Computer Associates International Lines: 48 First some info: I am using MS-C 6.0a and MS-C 3.0a. I am calling a function from a .exe that is in a DLL. This function does an fopen() and then returns a FILE *. Within the DLL I am able to fprintf() to the file, but when I try to call fprintf() from my .exe it fails, with the following pop up box in CodeView: Trap 13 (0DH) - General Protection Fault Am I doing something wrong or is impossible to call fopen() from within a DLL and return the FILE * to the exe? basic function in DLL: FILE *my_fopen( char *psFileName, char *psMode ) { FILE *pFile; pFile = fopen( psFileName, psMode ); if( pFile != NULL ) fprintf( pFile, "\n This works in the DLL" ); return( pFile ); } basic function in .exe called from WinMain(): int my_func() { FILE *pFile; pFile = my_fopen( "file.tmp", "w" ); if( pFile != NULL ) { fprintf( pFile, "\n This does not work!, get CVW pop up box!" ); fclose( pFile ); } } The examples above may have syntax errors, but they should help your understanding of my problem. I do not get the chance to read news that often, so please mail me your responses. Many many thanks in advance. -- Dean Grammas..............................................dxg@cai.com "All I ask is a chance to prove that money can't make me happy." .....................................................................