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.

194 lines
4.6 KiB

  1. //*************************************************************
  2. // File name: INIT.C
  3. //
  4. // Description: Initialization code for Profile control panel
  5. // applet
  6. //
  7. //
  8. // Microsoft Confidential
  9. // Copyright (c) Microsoft Corporation 1992-1994
  10. // All rights reserved
  11. //
  12. //*************************************************************
  13. #include <windows.h>
  14. #include <cpl.h>
  15. #include "profile.h"
  16. //*************************************************************
  17. //
  18. // DllInitialize()
  19. //
  20. // Purpose: Main entry point
  21. //
  22. //
  23. // Parameters: HINSTANCE hInstDLL - Instance handle of DLL
  24. // DWORD dwReason - Reason DLL was called
  25. // LPVOID lpvReserved - NULL
  26. //
  27. //
  28. // Return: BOOL
  29. //
  30. //*************************************************************
  31. BOOL DllInitialize(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
  32. {
  33. if (dwReason != DLL_PROCESS_ATTACH) {
  34. return TRUE;
  35. }
  36. hInstance = hInstDLL;
  37. DisableThreadLibraryCalls(hInstDLL);
  38. return TRUE;
  39. }
  40. //*************************************************************
  41. //
  42. // CPlApplet()
  43. //
  44. // Purpose: Control Panel entry point
  45. //
  46. //
  47. // Parameters: HWND hwnd - Window handle
  48. // WORD wMsg - Control Panel message
  49. // LPARAM lParam1 - Long parameter
  50. // LPARAM lParam2 - Long parameter
  51. //
  52. //
  53. // Return: LONG
  54. //
  55. //*************************************************************
  56. LONG CPlApplet( HWND hwnd, WORD wMsg, LPARAM lParam1, LPARAM lParam2)
  57. {
  58. LPNEWCPLINFO lpNewCplInfo;
  59. LPCPLINFO lpCplInfo;
  60. switch (wMsg) {
  61. case CPL_INIT:
  62. if (CheckProfileType()) {
  63. uiShellHelp = RegisterWindowMessage (szShellHelp);
  64. return TRUE;
  65. } else {
  66. return FALSE;
  67. }
  68. break;
  69. case CPL_GETCOUNT:
  70. return (LONG)NUM_APPLETS;
  71. case CPL_INQUIRE:
  72. lpCplInfo = (LPCPLINFO)lParam2;
  73. lpCplInfo->idIcon = ID_ICON;
  74. lpCplInfo->idName = IDS_NAME;
  75. lpCplInfo->idInfo = IDS_INFO;
  76. lpCplInfo->lData = 0L;
  77. return (LONG)TRUE;
  78. case CPL_NEWINQUIRE:
  79. lpNewCplInfo = (LPNEWCPLINFO)lParam2;
  80. lpNewCplInfo->hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(ID_ICON));
  81. if (!LoadString( hInstance, IDS_NAME, lpNewCplInfo->szName,
  82. sizeof(lpNewCplInfo->szName))) {
  83. lpNewCplInfo->szName[0] = TEXT('\0');
  84. }
  85. if(!LoadString( hInstance, IDS_INFO, lpNewCplInfo->szInfo,
  86. sizeof(lpNewCplInfo->szInfo))) {
  87. lpNewCplInfo->szInfo[0] = TEXT('\0');
  88. }
  89. lpNewCplInfo->dwSize = sizeof(NEWCPLINFO);
  90. lpNewCplInfo->dwHelpContext = HELP_CONTEXT;
  91. if(!LoadString( hInstance, IDS_INFO, lpNewCplInfo->szHelpFile,
  92. sizeof(lpNewCplInfo->szHelpFile))) {
  93. lpNewCplInfo->szHelpFile[0] = TEXT('\0');
  94. }
  95. return (LONG)TRUE;
  96. case CPL_DBLCLK:
  97. RunApplet(hwnd);
  98. break;
  99. }
  100. return (LONG)0;
  101. }
  102. //*************************************************************
  103. //
  104. // CheckProfileType()
  105. //
  106. // Purpose: Checks to see if this user has a floating
  107. // personal profile. This is done by looking
  108. // in the registry for the "ProfileType" entry.
  109. //
  110. // 0 = local non-floating profile
  111. // 1 = personal floating (.usr) profile
  112. // 2 = manditory profile
  113. //
  114. // Parameters: void
  115. //
  116. //
  117. // Return: BOOL - TRUE if this applet should load
  118. // FALSE if not
  119. //
  120. //*************************************************************
  121. BOOL CheckProfileType (void)
  122. {
  123. LONG lResult;
  124. HKEY hKey;
  125. DWORD dwType, dwMaxBufferSize;
  126. TCHAR szTempBuffer [MAX_TEMP_BUFFER];
  127. //
  128. // Open the registry key
  129. //
  130. lResult = RegOpenKeyEx (HKEY_CURRENT_USER, szProfileRegInfo, 0,
  131. KEY_ALL_ACCESS, &hKey);
  132. if (lResult != ERROR_SUCCESS) {
  133. return FALSE;
  134. }
  135. //
  136. // Query for the profile path
  137. //
  138. dwMaxBufferSize = MAX_TEMP_BUFFER;
  139. szTempBuffer[0] = TEXT('\0');
  140. lResult = RegQueryValueEx (hKey, szProfileType, NULL, &dwType,
  141. (LPBYTE) szTempBuffer, &dwMaxBufferSize);
  142. //
  143. // Close the registry key and return the appropriate response.
  144. //
  145. RegCloseKey (hKey);
  146. if (lResult != ERROR_SUCCESS) {
  147. return FALSE;
  148. }
  149. if (szTempBuffer[0] == PERSONAL_PROFILE_TYPE) {
  150. return TRUE;
  151. } else {
  152. return FALSE;
  153. }
  154. }