Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. dllinit.c
  5. Abstract:
  6. This module contians the DLL attach/detach event entry point for
  7. the Stadard C2 function dll
  8. Author:
  9. Bob Watson (a-robw) Dec-94
  10. Revision History:
  11. --*/
  12. #include <windows.h>
  13. #include <c2inc.h>
  14. #include <c2dll.h>
  15. #include "c2acls.h"
  16. #include "c2aclres.h"
  17. static HANDLE ThisDLLHandle = NULL;
  18. int
  19. DisplayDllMessageBox (
  20. IN HWND hWnd,
  21. IN UINT nMessageId,
  22. IN UINT nTitleId,
  23. IN UINT nStyle
  24. )
  25. /*++
  26. Routine Description:
  27. Displays a message box displaying text from the DLL's resource file, as
  28. opposed to literal strings.
  29. Arguments:
  30. IN HWND hWnd window handle to parent window
  31. IN UINT nMessageId String Resource ID of message text to display
  32. IN UINT nTitleId String Resource ID of title text to display
  33. IN UINT nStyle MB style bits (see MessageBox function)
  34. Return Value:
  35. ID of button pressed to exit message box
  36. --*/
  37. {
  38. LPTSTR szMessageText = NULL;
  39. LPTSTR szTitleText = NULL;
  40. HINSTANCE hInst;
  41. int nReturn;
  42. hInst = GetDllInstance();
  43. szMessageText = GLOBAL_ALLOC (SMALL_BUFFER_BYTES);
  44. szTitleText = GLOBAL_ALLOC (SMALL_BUFFER_BYTES);
  45. if ((szMessageText != NULL) &&
  46. (szTitleText != NULL)) {
  47. LoadString (hInst,
  48. ((nTitleId != 0) ? nTitleId : IDS_DLL_NAME),
  49. szTitleText,
  50. SMALL_BUFFER_SIZE -1);
  51. LoadString (hInst,
  52. nMessageId,
  53. szMessageText,
  54. SMALL_BUFFER_SIZE - 1);
  55. nReturn = MessageBox (
  56. hWnd,
  57. szMessageText,
  58. szTitleText,
  59. nStyle);
  60. } else {
  61. nReturn = IDCANCEL;
  62. }
  63. GLOBAL_FREE_IF_ALLOC (szMessageText);
  64. GLOBAL_FREE_IF_ALLOC (szTitleText);
  65. return nReturn;
  66. }
  67. HINSTANCE
  68. GetDllInstance (
  69. )
  70. {
  71. return (HINSTANCE)ThisDLLHandle;
  72. }
  73. BOOL
  74. DLLInit(
  75. IN HANDLE DLLHandle,
  76. IN DWORD Reason,
  77. IN LPVOID ReservedAndUnused
  78. )
  79. {
  80. ReservedAndUnused;
  81. switch(Reason) {
  82. case DLL_PROCESS_ATTACH:
  83. ThisDLLHandle = DLLHandle;
  84. break;
  85. case DLL_PROCESS_DETACH:
  86. break ;
  87. case DLL_THREAD_ATTACH:
  88. case DLL_THREAD_DETACH:
  89. break;
  90. }
  91. return(TRUE);
  92. }
  93.