How can I handle file I/O in DLL?

How can I handle file I/O in DLL?

Post by sui.. » Mon, 16 Dec 1996 04:00:00

I have difficulty to handle file I/O in DLL. The fopen() works fine in
.EXE. But once I add the codes to the DLL, it cannot read the file. Why?

The following are my DLL:

// Convert the function into PASCAL standards.
UINT FAR _pascal ORAWFAttachImageToCase(char * lpszDatabaseName)
    FILE * pInFilePtr;
    char szDatabaseName[81] = {NULL};
    char szDatabasePath[81] = {NULL};
    char szInFileName[] = "C:\\WORK\\WOI.INI";
    char szFunctionName[] = "ORAWFCASE.ORAWFCreateImageDocInCase";
    int  iReturnCode;

    //If the file cannot be opened, do nothing.
   if ((pInFilePtr = fopen (szInFileName, "r" )) == NULL)
        MessageBox(NULL, "The file WOI.INI cannot not be opened.\n",
                 szFunctionName, MB_ICONHAND);
           fclose (pInFilePtr);

         //If the database name is not passed by the calling program,
         //display error.
           if (lpszDatabaseName == NULL)
             MessageBox(NULL, "No image database is supplied by the
                       calling program.\n", szFunctionName, MB_ICONHAND);
           //If the program cannot get the database path, display error.
           //If it does, modify the database path.
             iReturnCode = GetPrivateProfileString("Databases",
                         lpszDatabaseName, " ",
                         szDatabasePath, sizeof(szDatabasePath),

           if (iReturnCode == NULL)
                  MessageBox(NULL, "No image database is specified in
                         WOI.INI.\n", szFunctionName, MB_ICONHAND);
              iReturnCode = WritePrivateProfileString("O/i", "DMSysPath",
                            szDatabasePath, szInFileName);



Best regards,




1. Getting file handle info knowing only the file handle

Sorry if this has been answered before, but I can only go back a couple
weeks with my news server.

If I use a tools like the reskit OH.EXE to dump the handles for a process,
how can I get additional information for the handle given that I know the
process id, and the handle value?  OH is run to dump un-named objects too,
and on a large/intensive server application I'm getting a lot of un-named
file handles.  How do I find out more information, like what the handle is
attached to (file, socket, etc.), which thread created it, etc.  Can this be
done programmatically from within the server application?  Are there any
utilities for viewing all the information with regards to a handle (file,
event, thread, key, mutant, section, etc.)?

2. Outlook OWA access

3. MS-WORD 6.0 WLL & ODBC DLL Add-Ins

4. Instruction alignment

5. Sharing file handles amongst DLL calls from NTVDM

6. Testmanagement Tools wanted

7. Passing file handles to DLL's

8. Pocket Informant Work in Outlook2002???

9. HELP: How do you execute an .INS file _without_ Internet Explorer v3.0x installed?

10. Dial Up Networking .INS file

11. VDD, DLLs and sharing file handles ++help please

12. VB file handles->DLLs??

13. help wanted with DLL and high level file handling