Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dllmain.c

Go to the documentation of this file.
00001 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 00002 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 00003 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 00004 // PARTICULAR PURPOSE. 00005 // 00006 // Copyright (C) 1993-1995 Microsoft Corporation. All Rights Reserved. 00007 // 00008 // MODULE: dllmain.c 00009 // 00010 // PURPOSE: Contains the DLL's entry point function. 00011 // 00012 // FUNCTIONS: 00013 // DLLMain - The entry point function 00014 // 00015 00016 #include <windows.h> 00017 00018 00019 // 00020 // FUNCTION: DLLMain(HINSTANCE, DWORD, LPVOID) 00021 // 00022 // PURPOSE: Called when DLL is loaded by a process, and when new 00023 // threads are created by a process that has already loaded the 00024 // DLL. Also called when threads of a process that has loaded the 00025 // DLL exit cleanly and when the process itself unloads the DLL. 00026 // 00027 // PARAMETERS: 00028 // hDLLInst - Instance handle of the DLL 00029 // fdwReason - Process attach/detach or thread attach/detach 00030 // lpvReserved - Reserved and not used 00031 // 00032 // RETURN VALUE: (Used only when fdwReason == DLL_PROCESS_ATTACH) 00033 // TRUE - Used to signify that the DLL should remain loaded. 00034 // FALSE - Used to signify that the DLL should be immediately unloaded. 00035 // 00036 // COMMENTS: 00037 // 00038 // If you want to use C runtime libraries, keep this function named 00039 // "DllMain" and you won't have to do anything special to initialize 00040 // the runtime libraries. 00041 // 00042 // When fdwReason == DLL_PROCESS_ATTACH, the return value is used to 00043 // determine if the DLL should remain loaded, or should be immediately 00044 // unloaded depending upon whether the DLL could be initialized properly. 00045 // For all other values of fdwReason, the return value is ignored. 00046 // 00047 00048 BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) 00049 { 00050 switch (fdwReason) 00051 { 00052 case DLL_PROCESS_ATTACH: 00053 // The DLL is being loaded for the first time by a given process. 00054 // Perform per-process initialization here. If the initialization 00055 // is successful, return TRUE; if unsuccessful, return FALSE. 00056 00057 break; 00058 00059 case DLL_PROCESS_DETACH: 00060 // The DLL is being unloaded by a given process. Do any 00061 // per-process clean up here, such as undoing what was done in 00062 // DLL_PROCESS_ATTACH. The return value is ignored. 00063 00064 break; 00065 00066 case DLL_THREAD_ATTACH: 00067 // A thread is being created in a process that has already loaded 00068 // this DLL. Perform any per-thread initialization here. The 00069 // return value is ignored. 00070 00071 break; 00072 00073 case DLL_THREAD_DETACH: 00074 // A thread is exiting cleanly in a process that has already 00075 // loaded this DLL. Perform any per-thread clean up here. The 00076 // return value is ignored. 00077 00078 break; 00079 } 00080 return TRUE; 00081 }

Generated on Sat May 15 19:39:45 2004 for test by doxygen 1.3.7