--- q_a/samples/simpldll/the_dll.c 2018/08/09 18:29:27 1.1.1.2 +++ q_a/samples/simpldll/the_dll.c 2018/08/09 18:29:49 1.1.1.3 @@ -1,3 +1,14 @@ + +/******************************************************************************\ +* This is a part of the Microsoft Source Code Samples. +* Copyright (C) 1993 Microsoft Corporation. +* All rights reserved. +* This source code is only intended as a supplement to +* Microsoft Development Tools and/or WinHelp documentation. +* See these sources for detailed information regarding the +* Microsoft samples programs. +\******************************************************************************/ + /******************************************************************************\ * * MODULE: THE_DLL.C @@ -9,7 +20,7 @@ * which loads a dialog template from the attached resource * file. * -* FUNCTIONS: DLLEntryPoint() - DLL entry point +* FUNCTIONS: DllMain() - DLL entry point * DLLFunction1() - skeleton function with no inputs * DLLFunction2() - skeleton function with int input * DLLFunction3() - skeleton function with HANDLE input @@ -18,17 +29,13 @@ * DLLDlgProc() - dialog window procedure * * COMMENTS: Another name may be used for the entry point -* ("DLLEntryPoint" is only an example). If no initialization +* ("DllMain" is only an example). If no initialization * or notification is required in a DLL, the DLL entry point * may be omitted. In either case, make sure to modify the -* "-entry:DLLEntryPoint" part of the DLL's link line in the +* "-entry:DllMain" part of the DLL's link line in the * makefile; either substitute the new entry point name, or * delete the line altogether (if omitting the entry point). * -* -* Microsoft Developer Support -* Copyright (c) 1992 Microsoft Corporation -* \******************************************************************************/ #include @@ -38,7 +45,7 @@ /******************************************************************************\ * -* FUNCTION: DLLEntryPoint +* FUNCTION: DllMain * * INPUTS: hDLL - handle of DLL * dwReason - indicates why DLL called @@ -57,17 +64,17 @@ * COMMENTS: The function will display a dialog box informing user of * each notification message & the name of the attaching/ * detaching process/thread. For more information see -* "DLLEntryPoint" in the Win32 API reference. +* "DllMain" in the Win32 API reference. * \******************************************************************************/ -BOOL WINAPI DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved) +BOOL WINAPI DllMain (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: { - char buf[BUFSIZE]; + char buf[BUFSIZE+1]; // // DLL is attaching to the address space of the current process. @@ -75,8 +82,10 @@ BOOL WINAPI DLLEntryPoint (HANDLE hDLL, ghMod = hDLL; GetModuleFileName (NULL, (LPTSTR) buf, BUFSIZE); - MessageBox (NULL, (LPCTSTR) buf, (LPCTSTR) "THE_DLL: Process attaching", - MB_OK); + MessageBox ( GetFocus(), + (LPCTSTR) buf, + (LPCTSTR) "THE_DLL: Process attaching", + MB_OK | MB_SYSTEMMODAL); break; } @@ -86,8 +95,10 @@ BOOL WINAPI DLLEntryPoint (HANDLE hDLL, // A new thread is being created in the current process. // - MessageBox (NULL, (LPCTSTR) "THE_DLL: Thread attaching", (LPCTSTR) "", - MB_OK); + MessageBox ( GetFocus(), + (LPCTSTR) "THE_DLL: Thread attaching", + (LPCTSTR) "", + MB_OK | MB_SYSTEMMODAL); break; case DLL_THREAD_DETACH: @@ -96,8 +107,10 @@ BOOL WINAPI DLLEntryPoint (HANDLE hDLL, // A thread is exiting cleanly. // - MessageBox (NULL, (LPCTSTR) "THE_DLL: Thread detaching", (LPCTSTR) "", - MB_OK); + MessageBox ( GetFocus(), + (LPCTSTR) "THE_DLL: Thread detaching", + (LPCTSTR) "", + MB_OK | MB_SYSTEMMODAL); break; case DLL_PROCESS_DETACH: @@ -105,13 +118,14 @@ BOOL WINAPI DLLEntryPoint (HANDLE hDLL, // // The calling process is detaching the DLL from its address space. // - - MessageBox (NULL, (LPCTSTR) "THE_DLL: Process detaching", (LPCTSTR) "", - MB_OK); + MessageBox ( GetFocus(), + (LPCTSTR) "THE_DLL: Process detaching", + (LPCTSTR) "", + MB_OK | MB_SYSTEMMODAL ); break; } - return TRUE; +return TRUE; }