LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

abort DllMain

Hi,
In the sample project "guidll.prj" it says in the guidll.c file at the end of DllMain:
 
/* return 0 to abort if initialization fails */
return 1;
 
Does it make a difference to return 1 or 0 from the DllMain?
 
Assume that something goes wrong during the initalizations we make in DLL_PROCESS_ATTACH part of DllMain.
How can we make the calling application (one that loads and wants to use our dll) aware of that suitably?
Is returning 0 or 1 makes a difference for that application, by default?
 
If there is an error during the initalization we probably want to prevent the user application from calling other functions from our dll.
Does returning 0 from DllMain do that?
 
Thanks.
S. Eren BALCI
IMESTEK
0 Kudos
Message 1 of 2
(3,340 Views)
Here's the info from the Win32 SDK on DLLMain return codes:

When the system calls the DLLMain function with the DLL_PROCESS_ATTACH value, the function returns TRUE if it succeeds or FALSE if initialization fails. If the return value is FALSE when DLLMain is called because the process uses the LoadLibrary function, LoadLibrary returns NULL. (The system immediately calls your entry-point function with DLL_PROCESS_DETACH and unloads the DLL.) If the return value is FALSE when DLLMain is called during process initialization, the process terminates with an error. To get extended error information, call GetLastError.

When the system calls the DLLMain function with any value other than DLL_PROCESS_ATTACH, the return value is ignored.


The Win32 SDK is available on line at the microsoft website and it's included in the CVI FSD version.


Menchar


Message 2 of 2
(3,327 Views)