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.

91 lines
2.3 KiB

  1. #include <windows.h>
  2. #include <ceconfig.h>
  3. PFN_CREATECURSOR g_pCreateCursor;
  4. CE_CONFIG g_CEConfig;
  5. BOOL g_CEUseScanCodes;
  6. BOOL UTREG_UI_DEDICATED_TERMINAL_DFLT;
  7. void CEInitialize(void)
  8. {
  9. // no need to free coredll.dll, it's used by bascially everything already.
  10. HINSTANCE hLib = LoadLibrary(L"coredll.dll");
  11. if (!hLib)
  12. {
  13. g_pCreateCursor = NULL;
  14. return;
  15. }
  16. g_pCreateCursor = (PFN_CREATECURSOR) GetProcAddress(hLib,L"CreateCursor");
  17. }
  18. CE_CONFIG CEGetConfigType(BOOL *CEUseScanCodes)
  19. {
  20. HKEY hkey = 0;
  21. TCHAR szConfig[256];
  22. DWORD dwType;
  23. DWORD dwValue;
  24. DWORD dwSize = sizeof(szConfig);
  25. CE_CONFIG CEConfig;
  26. if(ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE,UTREG_CE_CONFIG_KEY,
  27. 0, KEY_ALL_ACCESS, &hkey))
  28. {
  29. if (CEUseScanCodes)
  30. {
  31. *CEUseScanCodes = UTREG_CE_USE_SCAN_CODES_DFLT;
  32. }
  33. return UTREG_CE_CONFIG_TYPE_DFLT;
  34. }
  35. if (ERROR_SUCCESS != RegQueryValueEx(hkey,UTREG_CE_CONFIG_NAME, 0, &dwType, (LPBYTE)&szConfig,&dwSize))
  36. {
  37. CEConfig = UTREG_CE_CONFIG_TYPE_DFLT;
  38. }
  39. else if (0 == lstrcmpi(szConfig,TEXT("Maxall")))
  40. {
  41. CEConfig = CE_CONFIG_MAXALL;
  42. }
  43. else if (0 == lstrcmpi(szConfig,TEXT("Minshell")))
  44. {
  45. CEConfig = CE_CONFIG_MINSHELL;
  46. }
  47. else if (0 == lstrcmpi(szConfig,TEXT("Rapier")) || 0 == lstrcmpi(szConfig,TEXT("PalmSized")))
  48. {
  49. CEConfig = CE_CONFIG_PALMSIZED;
  50. }
  51. else
  52. {
  53. CEConfig = UTREG_CE_CONFIG_TYPE_DFLT;
  54. }
  55. // CEUseScanCodes is optional and may be NULL
  56. if (CEUseScanCodes)
  57. {
  58. if (ERROR_SUCCESS != RegQueryValueEx(hkey,UTREG_CE_USE_SCAN_CODES, 0, &dwType, (LPBYTE)&dwValue, &dwSize))
  59. {
  60. // This keeps things the way they were by default in WBT and Cerburus project
  61. // if there is no overriding registry key.
  62. if (CEConfig == CE_CONFIG_WBT)
  63. {
  64. *CEUseScanCodes = 1;
  65. }
  66. else
  67. {
  68. *CEUseScanCodes = 0;
  69. }
  70. }
  71. else
  72. {
  73. *CEUseScanCodes = (dwValue ? 1 : 0);
  74. }
  75. }
  76. if (hkey)
  77. RegCloseKey(hkey);
  78. return CEConfig;
  79. }