Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calling fopen in DLL called from VB?

Posted on 1997-05-23
2
Medium Priority
?
841 Views
Last Modified: 2013-12-03
We've written a 16 bit DLL in C++ that opens file using the MFC CStdioFile and CFile classes.  These use the fopen C
runtime library function and the _dos_open library
function respectively.

The problem is that when this DLL is called from an Access
Basic (V2)application or a VB (V4) application that has an
Access database open, the opens of CStdioFile
objects sometimes fail.  The m_cause member of
the associated CFileException object returns a 1
(generic) and the m_lOsError member contains 0.

The problem does not occur when called from a non-Access
VB application or from applications written in C++ (no
Access).

At the time of the failure, the DLL has only one other
file open (CStdioFile) and is trying to open another
CStdioFile.

The problem occurs in both Windows 3.x and Win95.

I found one short and unresolved thread on what sounded
like the same problem. One contributor pointed to a MSDN
article entitled "Creating Custom Add-in Libraries for
Word 6.0 Using the Word API."  This article suggests that
using text mode DOS file handles is not guaranteed to work
in a DLL called from Word.  The author of the referencing
newsgroup message suggested that this may be true for
VB and Access Basic as well.  While this might explain
the behaviour, I am skeptical.

Thanks.
0
Comment
Question by:NickDanger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
ajh020797 earned 400 total points
ID: 1397624
If the problem is purely with text files, why fopen with the binary flag set and remember to put \r\n instead of \n ?
0
 

Author Comment

by:NickDanger
ID: 1397625
Thanks ajh!
I was looking for an explanation however.  I've since been
able to "fix" the problem, by increasing the file handle
count in my DLL (ala MSDN article "Increasing File Handles"
found in section 2.7 of the Runtime Library Reference).

While this seems to have fixed the problem, I am still troubled
since I cannot explain it.

Thanks again.

0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question