--- q_a/samples/simpldll/the_dll.c 2018/08/09 18:29:19 1.1.1.1 +++ q_a/samples/simpldll/the_dll.c 2018/08/09 18:29:27 1.1.1.2 @@ -1,4 +1,4 @@ -/************************************************************************\ +/******************************************************************************\ * * MODULE: THE_DLL.C * @@ -25,14 +25,18 @@ * 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 #include "the_dll.h" -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLEntryPoint * @@ -48,77 +52,87 @@ * Normally the function would return TRUE if DLL initial- * ization succeeded, or FALSE it it failed. * -* GLOBAL VARS: hMod - handle of DLL (initialized when PROCESS_ATTACHes) +* GLOBAL VARS: ghMod - handle of DLL (initialized when PROCESS_ATTACHes) * * 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. * -\************************************************************************/ +\******************************************************************************/ -BOOL DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved) -{ switch (dwReason) - { case DLL_PROCESS_ATTACH: - { char buf[BUFSIZE]; - - /******************************************************************\ - * DLL is attaching to the address space of the current process. - \******************************************************************/ +BOOL WINAPI DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + { + char buf[BUFSIZE]; + + // + // DLL is attaching to the address space of the current process. + // - hMod = hDLL; + ghMod = hDLL; GetModuleFileName (NULL, (LPTSTR) buf, BUFSIZE); - MessageBox (NULL, buf, "THE_DLL: Process attaching", MB_OK); + MessageBox (NULL, (LPCTSTR) buf, (LPCTSTR) "THE_DLL: Process attaching", + MB_OK); break; } + case DLL_THREAD_ATTACH: - /******************************************************************\ - * A new thread is being created in the current process. - \******************************************************************/ + // + // A new thread is being created in the current process. + // - MessageBox (NULL, "THE_DLL: Thread attaching", "", MB_OK); + MessageBox (NULL, (LPCTSTR) "THE_DLL: Thread attaching", (LPCTSTR) "", + MB_OK); break; + case DLL_THREAD_DETACH: - /******************************************************************\ - * A thread is exiting cleanly. - \******************************************************************/ + // + // A thread is exiting cleanly. + // - MessageBox (NULL, "THE_DLL: Thread detaching", "", MB_OK); + MessageBox (NULL, (LPCTSTR) "THE_DLL: Thread detaching", (LPCTSTR) "", + MB_OK); break; + case DLL_PROCESS_DETACH: - /******************************************************************\ - * The calling process is detaching the DLL from its address space. - \******************************************************************/ + // + // The calling process is detaching the DLL from its address space. + // - MessageBox (NULL, "THE_DLL: Process detaching", "", MB_OK); + MessageBox (NULL, (LPCTSTR) "THE_DLL: Process detaching", (LPCTSTR) "", + MB_OK); break; } + return TRUE; - UNREFERENCED_PARAMETER(hDLL); - UNREFERENCED_PARAMETER(lpReserved); } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLFunction1 * * RETURNS: 1 * -\************************************************************************/ +\******************************************************************************/ INT DLLFunction1 () -{ MessageBeep (0); +{ + MessageBeep (0); return 1; } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLFunction2 * @@ -126,17 +140,17 @@ INT DLLFunction1 () * * RETURNS: 1 * -\************************************************************************/ +\******************************************************************************/ INT DLLFunction2 (int i) -{ MessageBeep (0); +{ + MessageBeep (0); return 1; - UNREFERENCED_PARAMETER(i); } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLFunction3 * @@ -144,17 +158,17 @@ INT DLLFunction2 (int i) * * RETURNS: 1 * -\************************************************************************/ +\******************************************************************************/ INT DLLFunction3 (HANDLE h) -{ MessageBeep (0); +{ + MessageBeep (0); return 1; - UNREFERENCED_PARAMETER(h); } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLFunction4 * @@ -162,17 +176,17 @@ INT DLLFunction3 (HANDLE h) * * RETURNS: 1 * -\************************************************************************/ +\******************************************************************************/ INT DLLFunction4 (HWND hwnd) -{ MessageBeep (0); +{ + MessageBeep (0); return 1; - UNREFERENCED_PARAMETER(hwnd); } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLDialogBox * @@ -180,31 +194,30 @@ INT DLLFunction4 (HWND hwnd) * * RETURNS: 1 * -\************************************************************************/ +\******************************************************************************/ INT DLLDialogBox (HWND hwndParent) -{ DialogBox (hMod, (LPTSTR) "DLLDlg", hwndParent, DLLDlgProc); +{ + DialogBox (ghMod, (LPCTSTR) "DLLDlg", hwndParent, (DLGPROC) DLLDlgProc); return 1; } -/************************************************************************\ +/******************************************************************************\ * * FUNCTION: DLLDlgProc (standard dialog procedure INPUTS/RETURNS) * -\************************************************************************/ +\******************************************************************************/ -BOOL DLLDlgProc (HWND hDlg, UINT msg, UINT wParam, LONG lParam) -{ switch (msg) - { case WM_INITDIALOG: - return (TRUE); +LRESULT CALLBACK DLLDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { case WM_COMMAND: + EndDialog(hDlg, TRUE); return (TRUE); } return (FALSE); - UNREFERENCED_PARAMETER(hDlg); - UNREFERENCED_PARAMETER(wParam); - UNREFERENCED_PARAMETER(lParam); }