15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Using a class in One DLL from a class in another DLL

Norman L Covington -- doubleM@cris.com
Monday, July 15, 1996

Dear list members:

VC++ 4.1 WIN95/WIN NT

I have two extention DLLs (more after I get these two working) that call 
one another (I guess you would call it "across" the EXE). One DLL 
contains some domain classes that are going to be commonly used in the 
future. The second DLL contains domain classes that will be used in some 
future applications. A third DLL will be created that will contain data 
manipulation (DAO, ODBC, MSSQL) depending on configuration by the user.

What or how are __declspec(dllimport), __declspec(dllexport), or 
AFX_CLASS_EXPORT[???] used to accomplish this process. I have checked 
Mike Blaszczak's MFC 4 Programming with the Visual C++, Advanced Windows 
by Jeffrey Richter  (which doesn't address MFC Extension DLLs), George 
Shepard and Scot Wingo's MFC Internals (which stated it would address the 
issue in chapter 10, but that section was left out ---- admittedly by one 
of the authors after contacted), Programming Windows 95 with MFC by Jeff 
Prosise (which doesn't even address creating DLLs - shocking to say the 
least). So, my point being I haven't brought this forward without first 
trying my hands at personal research.

No one discusses calling a DLL class from one DLL that is contained in 
another DLL (both being MFC Extension DLLs). Could someone please assist 
in describing how this is accomplished in a neat and orderly fashion???

Thank you in advance!!!

Norman




Herb Stahl -- HStahl@symantec.com
Saturday, July 20, 1996

[Mini-digest: 2 responses]

I am going to assume that you already know how to build 1 stand alone Extension
DLL.

Building Extension DLL1 which uses Extension DLL 2 and Extension DLL 3

1) in the preprocessor definitions  of the DLL1 project insert
BUILDING_EXTENSION_1
2) in the export header file of DLL1 place

// Extension DLL1 header dll1.h
#ifdef  BUILDING_EXTENSION_1
        #define BE1_AFX_EXT_CLASS         AFX_CLASS_EXPORT      /* stolen from
afxv_dll.h */
#else
        #define BE1_AFX_EXT_CLASS         AFX_CLASS_IMPORT      /* stolen from
afxv_dll.h */
#endif

class
BE1_AFX_EXT_CLASS
CSomeExportedClass: public CObject
{};


What this buys you:  Only the DLL being built will export it's classes.  Other
extension dll's will be imported into this DLL for use by this DLL.  This only
works if your other dll's follow the same convention.  Now simple link in the
other extension DLL's and there shouldn't be any conflicts.


If anyone has a cleaner way to do this, please contribute.
This works for me..

George Stahl.

----------
From:   mfc-l@netcom.com
Sent:   Saturday, July 20, 1996 12:44 PM
To:     mfc-l@netcom.com
Subject:        Using a class in One DLL from a class in another DLL

Dear list members:

VC++ 4.1 WIN95/WIN NT

I have two extention DLLs (more after I get these two working) that call 
one another (I guess you would call it "across" the EXE). One DLL 
contains some domain classes that are going to be commonly used in the 
future. The second DLL contains domain classes that will be used in some 
future applications. A third DLL will be created that will contain data 
manipulation (DAO, ODBC, MSSQL) depending on configuration by the user.

What or how are __declspec(dllimport), __declspec(dllexport), or 
AFX_CLASS_EXPORT[???] used to accomplish this process. I have checked 
Mike Blaszczak's MFC 4 Programming with the Visual C++, Advanced Windows 
by Jeffrey Richter  (which doesn't address MFC Extension DLLs), George 
Shepard and Scot Wingo's MFC Internals (which stated it would address the 
issue in chapter 10, but that section was left out ---- admittedly by one 
of the authors after contacted), Programming Windows 95 with MFC by Jeff 
Prosise (which doesn't even address creating DLLs - shocking to say the 
least). So, my point being I haven't brought this forward without first 
trying my hands at personal research.

No one discusses calling a DLL class from one DLL that is contained in 
another DLL (both being MFC Extension DLLs). Could someone please assist 
in describing how this is accomplished in a neat and orderly fashion???

Thank you in advance!!!

Norman

<>

-----From: tyuhl@pumatech.com


     You want to take a look at the Microsoft Knowledge Base Article "How 
     to Use _declspec(dllexport) in an MFC Extension DLL" (Q128199).  This 
     is a 4 page article that explains what you have to do when using 2 or 
     more extension DLLs that use classes in each other.




| Вернуться в корень Архива |