Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DLL

Posted on 1998-05-13
6
Medium Priority
?
939 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

670 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