Solved

CTime usage in Window DLL?

Posted on 1997-07-19
3
513 Views
Last Modified: 2013-11-20
According to the documentation on CTime, because
CTime uses strftime(), it is not supported in Windows
DLLs. Is this limitation restricted to 16-bit DLLs?
Why this limitation?
0
Comment
Question by:rocco
3 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1302685
I have used CTime in 32bit DLL's without any trouble. Iam not aware of this limitation under 16bit DLL's. What are you planning to do with Time in 16bit dll ?
0
 

Author Comment

by:rocco
ID: 1302686
I have no plans in using CTime in a 16-bit DLL, but I want
to make sure that something does not break because I got
lucky that is worked the first time. The documentation
states that I should not use this class in a DLL (it did
not state if 32-bit DLLs are safe). I remember something about
strtok() being unsafe in a medium memory model, but okay in
a large memory model. I am wondering if this special case
exist for strftime().

Thanks...
0
 
LVL 1

Accepted Solution

by:
kraken earned 50 total points
ID: 1302687
The deal with CTime is that strftime() is not re-entrant.  DLLs may be used by many programs at once on the system.  The code's ability to handle many different programs using it at once is known as re-entrancy.  Since strftime() is not re-entrant, you will work fine... maybe... for a while.  Detecting re-entrancy problems is always very difficult, since it has to do with timing and separate processes, sometimes separate applications.

Another major downside to CTime is that it is very limited.  You can't use it for birthdays, for example, because it only extends back to January 1, 1970 (unless, of course, you can guarantee that no one older than 26/27 is going to be stored on your application).

Use COleDateTime instead.  It sounds scarier, but it really isn't.  COleDateTime stores dates as double-precision floating points, and uses a set of specially-designed routines to ensure re-entrancy... and thread-safeness.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

821 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