Creating statically linked, non-MFC DLLs North Carolina

This article illustrates how to create and use Statically linked Non-MFC (Implicit) DLLs.

Local Companies

StreamLogic Inc.
704-771-1090
3030 Glen Summit Dr.
Charlotte, NC
D P Solutions Inc
336-854-7700
4411 W Market St
Greensboro, NC
Advantec Information Systems LLC
336-275-2832
2007 Yanceyville St
Greensboro, NC
Blue Lizard Technologies, inc.
(919) 858-8885
1151 Executive Circle
Cary, NC
Racarie Software
919-654-4560
201 Shannon Oaks Circle
Cary, NC
The Lead Tree
321-206-8283
306 North Rankin Street
Atkinson, NC
BuildLinks: Web-based Project Management for Home Builders
888-700-9470
3800 Paramount Parkway, Suite 100
Morrisville, NC
Software Design Inc
336-378-0900
1301 Carolina St
Greensboro, NC
Community Web
336-499-3001
133 Hicks St
Winston-Salem, NC
Quadland
(336) 714-7417
301 N. Main Street
Winston-Salem, NC

provided by: 
Originally published at Internet.com


This article was contributed by Tair Abdurman.

This article illustrates how to create and use Statically linked Non-MFC (Implicit) DLLs. In order to build applications using DLLs in this way you must have .dll distribution with .lib & .h files. Lemme create DLL which can export whole class with method and variable and global variable with global procedure. I call this as HookWorks because have used this code to window's hook, and leave without changes. To start from 0, select New->Project->Win32 DLL. Select empty project and click finish (no need to help from wizards! ;). First going to planning our exports and declare them in //**************HWMain.h file***************** //HWMain.h Non-MFC DLL header file //sure it will be included only once #ifndef _ATM_HWMAIN_H_ #define _ATM_HWMAIN_H_ #pragma once //to speedup & reduce size #define VC_EXTRALEAN //Header body You can use .DEF file if wanna to use ordinal exports, but here I use exports by names. Create some usefull macros //export macros #define DLL_EXPORT __declspec(dllexport) //import macro #define DLL_IMPORT __declspec(dllimport) After completing your DLL, you can use DUMPBIN [options] files to view export table of DLL. // ... #include //to export for C++ & C #ifdef __cplusplus extern "C" { #endif Here, the class will be exported with all of its members. Now you only need to create a new instance of the object and all members will be accessable //class export, with all definitions class DLL_EXPORT CHookWorks { public: //blah blah method int HookWorksFunc(void); //blah blah variable int m_iHookWorks; //con and decon CHookWorks(); _1_CHookWorks(); }; Here is a variable which will be accesable as extern in your "client" //exported variable DLL_EXPORT int exp_iVar=99; this function will be directly accessable //exported function DLL_EXPORT BOOL ExportedFunc(BOOL bParam); copmleted ... only close this "language unconveniences". #ifdef __cplusplus } #endif //EOF Header body #endif //*******************HWMain.h file********************** implementation is too simple with some explains: //*******************HWMain.cpp file******************** #include "HWMain.h" //Regular DLL Entry Point, do not have any importancy //to me here BOOL WINAPI DllMain(HINSTANCE hinstDLL, // DLL module handle DWORD fdwReason, // for calling function LPVOID lpvReserved // reserved ) { switch(fdwReason) { case DLL_PROCESS_ATTACH: /* Indicates that the DLL is being loaded into the virtual address space of the current process as a result of the process starting up or as a result of a call to LoadLibrary.DLLs can use this opportunity to initialize any instance data or to use the TlsAlloc function to allocate a Thread Local Storage (TLS) index.*/ break; case DLL_THREAD_ATTACH: /* Indicates that the current process is creating a new thread.When this occurs, the system calls the entry-point function of all DLLs currently attached to the process. The call is made in the context of the new thread. DLLs can use this opportunity to initialize a TLS slot for the thread. A thread calling the DLL entry-point function with DLL_PROCESS_ATTACH does not call the DLL entry-point function with DLL_THREAD_ATTACH. Note that a DLL's entry-point function is called with this value only by threads created after the DLL is loaded by the process. When a DLL is loaded using LoadLibrary, existing threads do not call the entry-point function of the newly loaded DLL.*/ break; case DLL_THREAD_DETACH: /* Indicates that a thread is exiting cleanly. If the DLL has stored a pointer too allocated memory in a TLS slot, it uses this opportunity to free the memory. The system calls the entry-point function of all currently loaded DLLs with this value. The call is made in the context of the exiting thread.*/ break; case DLL_PROCESS_DETACH: /* Indicates that the DLL is being unloaded from the virtual address space of the calling process as a result of either a process exit or a call to FreeLibrary. The DLL can use this opportunity to call the TlsFree function to free any TLS indices allocated by using TlsAlloc and to free any thread local data.*/ break; default: break; } return TRUE; } //class export, with all definitions //member method int CHookWorks::HookWorksFunc() { m_iHookWorks=10; return 2; } //constructor CHookWorks::CHookWorks() { m_iHookWorks=1; } //destructor CHookWorks::_1_CHookWorks() { } //exported function declaration DLL_EXPORT BOOL ExportedFunc(BOOL bParam) { return bParam; } //*******************HWMain.cpp file******************** Yep. It's ready. Simply compile after checking that you don't want MFC support (in the Linker settings). After building the project, you will 3 files that you need to distribute: * DEBUG build * HookWorks.dll * HookWorks.lib * HWMain.h * RELEASE build * HookWorks.dll * HookWorks.lib * HWMain.h The DLL must be stored in the same folder as the client application or in system DLL paths in order for it to be accessable from the client. If the client application can't find the DLL, you will receive an error message...

Read article at Internet.com site

Featured Local Company

The Lead Tree

321-206-8283
306 North Rankin Street
Atkinson, NC

Regional Articles
- Creating statically linked, non-MFC DLLs Albemarle NC
- Creating statically linked, non-MFC DLLs Apex NC
- Creating statically linked, non-MFC DLLs Arden NC
- Creating statically linked, non-MFC DLLs Asheboro NC
- Creating statically linked, non-MFC DLLs Asheville NC
- Creating statically linked, non-MFC DLLs Bessemer City NC
- Creating statically linked, non-MFC DLLs Boone NC
- Creating statically linked, non-MFC DLLs Brevard NC
- Creating statically linked, non-MFC DLLs Burlington NC
- Creating statically linked, non-MFC DLLs Camp Lejeune NC
- Creating statically linked, non-MFC DLLs Candler NC
- Creating statically linked, non-MFC DLLs Cary NC
- Creating statically linked, non-MFC DLLs Chapel Hill NC
- Creating statically linked, non-MFC DLLs Charlotte NC
- Creating statically linked, non-MFC DLLs Clayton NC
- Creating statically linked, non-MFC DLLs Clemmons NC
- Creating statically linked, non-MFC DLLs Clinton NC
- Creating statically linked, non-MFC DLLs Concord NC
- Creating statically linked, non-MFC DLLs Conover NC
- Creating statically linked, non-MFC DLLs Dunn NC
- Creating statically linked, non-MFC DLLs Durham NC
- Creating statically linked, non-MFC DLLs Eden NC
- Creating statically linked, non-MFC DLLs Elizabeth City NC
- Creating statically linked, non-MFC DLLs Fayetteville NC
- Creating statically linked, non-MFC DLLs Forest City NC
- Creating statically linked, non-MFC DLLs Fort Bragg NC
- Creating statically linked, non-MFC DLLs Fuquay Varina NC
- Creating statically linked, non-MFC DLLs Garner NC
- Creating statically linked, non-MFC DLLs Gastonia NC
- Creating statically linked, non-MFC DLLs Goldsboro NC
- Creating statically linked, non-MFC DLLs Granite Falls NC
- Creating statically linked, non-MFC DLLs Greensboro NC
- Creating statically linked, non-MFC DLLs Greenville NC
- Creating statically linked, non-MFC DLLs Havelock NC
- Creating statically linked, non-MFC DLLs Henderson NC
- Creating statically linked, non-MFC DLLs Hendersonville NC
- Creating statically linked, non-MFC DLLs Hickory NC
- Creating statically linked, non-MFC DLLs High Point NC
- Creating statically linked, non-MFC DLLs Hillsborough NC
- Creating statically linked, non-MFC DLLs Hope Mills NC
- Creating statically linked, non-MFC DLLs Huntersville NC
- Creating statically linked, non-MFC DLLs Jacksonville NC
- Creating statically linked, non-MFC DLLs Kannapolis NC
- Creating statically linked, non-MFC DLLs Kernersville NC
- Creating statically linked, non-MFC DLLs King NC
- Creating statically linked, non-MFC DLLs Kings Mountain NC
- Creating statically linked, non-MFC DLLs Kinston NC
- Creating statically linked, non-MFC DLLs Knightdale NC
- Creating statically linked, non-MFC DLLs Laurinburg NC
- Creating statically linked, non-MFC DLLs Leland NC
- Creating statically linked, non-MFC DLLs Lenoir NC
- Creating statically linked, non-MFC DLLs Lexington NC
- Creating statically linked, non-MFC DLLs Lillington NC
- Creating statically linked, non-MFC DLLs Lincolnton NC
- Creating statically linked, non-MFC DLLs Louisburg NC
- Creating statically linked, non-MFC DLLs Lumberton NC
- Creating statically linked, non-MFC DLLs Marion NC
- Creating statically linked, non-MFC DLLs Matthews NC
- Creating statically linked, non-MFC DLLs Mebane NC
- Creating statically linked, non-MFC DLLs Mocksville NC
- Creating statically linked, non-MFC DLLs Monroe NC
- Creating statically linked, non-MFC DLLs Mooresville NC
- Creating statically linked, non-MFC DLLs Morganton NC
- Creating statically linked, non-MFC DLLs Mount Airy NC
- Creating statically linked, non-MFC DLLs Mount Olive NC
- Creating statically linked, non-MFC DLLs Murphy NC
- Creating statically linked, non-MFC DLLs New Bern NC
- Creating statically linked, non-MFC DLLs North Wilkesboro NC
- Creating statically linked, non-MFC DLLs Raeford NC
- Creating statically linked, non-MFC DLLs Raleigh NC
- Creating statically linked, non-MFC DLLs Reidsville NC
- Creating statically linked, non-MFC DLLs Roanoke Rapids NC
- Creating statically linked, non-MFC DLLs Rockingham NC
- Creating statically linked, non-MFC DLLs Rocky Mount NC
- Creating statically linked, non-MFC DLLs Roxboro NC
- Creating statically linked, non-MFC DLLs Rutherfordton NC
- Creating statically linked, non-MFC DLLs Salisbury NC
- Creating statically linked, non-MFC DLLs Sanford NC
- Creating statically linked, non-MFC DLLs Shelby NC
- Creating statically linked, non-MFC DLLs Siler City NC
- Creating statically linked, non-MFC DLLs Statesville NC
- Creating statically linked, non-MFC DLLs Tarboro NC
- Creating statically linked, non-MFC DLLs Taylorsville NC
- Creating statically linked, non-MFC DLLs Thomasville NC
- Creating statically linked, non-MFC DLLs Trinity NC
- Creating statically linked, non-MFC DLLs Wake Forest NC
- Creating statically linked, non-MFC DLLs Waxhaw NC
- Creating statically linked, non-MFC DLLs Waynesville NC
- Creating statically linked, non-MFC DLLs Weaverville NC
- Creating statically linked, non-MFC DLLs Wendell NC
- Creating statically linked, non-MFC DLLs Whiteville NC
- Creating statically linked, non-MFC DLLs Williamston NC
- Creating statically linked, non-MFC DLLs Wilmington NC
- Creating statically linked, non-MFC DLLs Wilson NC
- Creating statically linked, non-MFC DLLs Winston Salem NC
- Creating statically linked, non-MFC DLLs Zebulon NC
Related Local Events
Automation Technology Expo South
Dates: 4/28/2010 - 4/29/2010
Location: Charlotte Convention Center
Charlotte, NC
View Details

Green Manufacturing Expo-Charlotte
Dates: 4/28/2010 - 4/29/2010
Location: Charlotte Convention Center
Charlotte, NC
View Details

Making the Right Decision with Business Intelligence and Analytics, NCTA Emerging Technologies & Trends Series
Dates: 2/10/2010 - 2/10/2010
Location: Belk Action Center
Charlotte, NC
View Details

North Carolina Legislative Holiday Reception (Govt. Affairs)
Dates: 12/3/2009 - 12/3/2009
Location: Washington Duke Inn & Golf Club
Durham, NC
View Details

North Carolina Legislative Holiday Reception (Govt. Affairs)
Dates: 12/3/2009 - 12/3/2009
Location: Washington Duke Inn & Golf Club
Durham, NC
View Details

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML