Solved

DLL

Posted on 1998-05-13
6
931 Views
Last Modified: 2013-12-03
WINDOWSer,

If I write a DLL in Visual C++ (not using MFC), must I need to use the DLLMain, LibMain or DLLEntryPoint ?
By the way, what are the differents between them and when will them be called ?

So, is it similiar to Main and WinMain ?

Andrew
0
Comment
Question by:andrewyu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 0 total points
ID: 1401414
LibMain is for 16-bit DLLs. DllEntryPoint is a placeholder for the library-defined function name. Visual C++ uses DllMain as the entry-point function name.

WinMain is for Windows GUI applications and main is for Windows Console applications.
0
 

Author Comment

by:andrewyu
ID: 1401415
By the way, must I need to use them ?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1401416
If you do not have some special initialization and cleanup to do, just write it as follows:

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    return TRUE;
}

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 22

Expert Comment

by:nietod
ID: 1401417
Chensu, you said that

>> DllEntryPoint is a placeholder for the library-defined function name

DllEntryPoint() is what Borland C++ DLLs use as attach/detach procedure (whatevery you want to call it).  DllMain() and DllEntryPoint() have the same functions, but are for different compilers.  They also have slightly different syntax.  

What's more, somehow no Borland C++ programers out there seem to use it to detach or somehow never seemd to notice a serious bug.  The procedure gets called twice to detach from a process.  This is in both BC 5.0 and builder 3.0.  It was never noticed until I reported it and it has not been fixed yet!

Andrew, if you are working with a borland compiler I'll post the borland syntax.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1401418
nietod,

Actually, it is not said by me. For your information, the following content is copied from the Platform SDK documentation.

DllEntryPoint
The DllEntryPoint function is an optional method of entry into a dynamic-link library (DLL). If the function is used, it is called by the system when processes and threads are initialized and terminated, or upon calls to the LoadLibrary and FreeLibrary functions.

DllEntryPoint is a placeholder for the library-defined function name. Many samples in the SDK use DllMain as the entry-point function name. You must specify the actual name you use when you build your DLL. For more information, see the documentation included with your development tools.

BOOL WINAPI DllEntryPoint(
  HINSTANCE hinstDLL,  // handle to DLL module
  DWORD fdwReason,     // reason for calling function
  LPVOID lpvReserved   // reserved
);

0
 
LVL 22

Expert Comment

by:nietod
ID: 1401419
Great more confussion.  But you should realize now that if somone uses the name DllEntryPoint()  they may be working under Borland.  And Borland does not seem to provide a way to change the name.  (I compile under poth and would like to th use the same procedure under both.)
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

628 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