| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | initinstance |
jd>
> what i want to do is to register a class in a dll.
>
> as far is a have understood i should create a asm-file
> containing a start-code, which jumps to my 'class-register-
> function' in a c-source. but i keep getting the error
> message 'multiple starting addresses found'. (?)
jd>
On the other hand, if you wish to be portable, ignore _DLL_InitTerm,
_dllmain, and __dll_initialize completely, and use C++.
Declare a class that represents the concept of your DLL
struct MyLibrary {
MyLibrary () ;
~MyLibrary () ;
} ;
Declare a single, static-duration, DLL-wide, instance of your derived
class in one of your DLL source files :
struct MyLibrary TheDLL ;
Note that `TheDLL' can have internal or external linkage (it matters
not). The important thing is that there is *one* static-duration
instance of that class in your whole DLL.
Perform all of your initialisation and cleanup in the constructor and
destructor of your DLL class :
MyLibrary::MyLibrary ()
{
WinRegisterClass(/*...*/) ;
}
MyLibrary::~MyLibrary () { /* Nothing for now */ }
These will then be called for `TheDLL' when the DLL is loaded and when
it is unloaded.
This has three advantages over the _DLL_InitTerm &c. method :
1. It's portable across all compilers. There's no need for
complex #if...#elif...#elif...#elif...#endif clauses.
2. It works for both statically and dynamically linked libraries.
3. You are guaranteed that the C++ runtime is available within
the constructor and destructor of `TheDLL' (calling constructors
and destructors of static-duration objects is *done* by the
C++ runtime, after all).
This method is thus highly recommended over the _DLL_InitTerm &c. method.
> JdeBP <
___
X MegaMail 2.10 #0:
--- Maximus/2 3.00
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 440/4 141/209 270/101 105/103 42 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.