On 15/01/2012 17:05, Damon Register wrote:
> I managed to get a little farther on this today. I was becoming convinced this had something to do with that _hInstance and Module stuff that I remember reading about.
After looking briefly at your problem yesterday, and I noticed that the
FAQ was no longer up-to-date for 6.32. I made some slight changes to
update the relevant Q&A. Although I don't think the changes are relevant
to your problem, it should hopefully be less confusing.
The key to understanding your problem is that owl::Module cannot be
everything to everyone. In particular, when building a DLL, you then
have three modules to consider: the client application (EXE), your DLL
and the OWLNext DLL.
You have to trace the initialization and assignments to owl::Module to
understand what it refers to. First, owl::Module is initialized before
OwlMain is called (see calls to InitGlobalModule in "_tmain" in
"main.cpp" and in OwlInitUserDLL in "initdll.cpp"). But then it is
usually reassigned to point to the application by the TApplication
constructor, unless you provide a different argument, and unless you
never create a TApplication, of course.
If you need a global variable/singleton to refer to your own DLL module,
or other external DLL modules, you should create your own, rather than
Aside: There is some confusing hocus-pocus performed when OWLNext is
built as a DLL. In this case owl::Module somehow always refers to the
OWLNext DLL within the OWLNext code. At least this is my current
understanding, and if correct, I suspect this is in breach of the C++
One Definition Rule. I want to simplify and correct this state of
affairs by introducing a separate variable to refer to the OWLNext
module (which may or may not refer to the same module as owl::Module,
depending on how the application is linked), and also remove the
redundant and confusing TAppDictionary (a Win16 artefact) and
PS. Can you send me a fully working test-case, i.e. main program and DLL
implementation? If you can provide a Visual Studio solution that would
be nice; otherwise provide all the build settings you use (e.g. generate