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.

148 lines
4.2 KiB

  1. //
  2. // File: UnicowsSupport.c
  3. // Date: 22 March 2001
  4. // Purpose: This file contains functions that supplement the Unicode wrapper layer
  5. //
  6. #define UNICODE
  7. #include "atlbase.h"
  8. #include "oledlg.h"
  9. static const char CDCommonFilesKey [] = "Software\\My Company",
  10. CDCommonFilesValueName [] = "UnicowsLocation",
  11. UnicowsName [] = "\\unicows.dll";
  12. static HMODULE __stdcall LoadUnicows (void)
  13. {
  14. HMODULE hUnicows = 0;
  15. HKEY hKey = 0;
  16. LONG errCode = RegOpenKeyExA (HKEY_LOCAL_MACHINE,
  17. CDCommonFilesKey,
  18. 0,
  19. KEY_READ,
  20. &hKey);
  21. if (errCode == ERROR_SUCCESS)
  22. {
  23. DWORD dwType = 0,
  24. cbData = 0;
  25. errCode = RegQueryValueExA (hKey,
  26. CDCommonFilesValueName,
  27. 0,
  28. &dwType,
  29. 0,
  30. &cbData);
  31. if (errCode == ERROR_SUCCESS && dwType == REG_SZ)
  32. {
  33. char *unicowsPath = (char *)alloca (cbData + strlen (UnicowsName));
  34. errCode = RegQueryValueExA (hKey,
  35. CDCommonFilesValueName,
  36. 0,
  37. &dwType,
  38. (BYTE *)unicowsPath,
  39. &cbData);
  40. if (errCode == ERROR_SUCCESS)
  41. {
  42. if (unicowsPath [strlen (unicowsPath) - 1] == '\\')
  43. strcat (unicowsPath, UnicowsName + 1);
  44. else
  45. strcat (unicowsPath, UnicowsName);
  46. hUnicows = LoadLibraryA (unicowsPath);
  47. }
  48. }
  49. RegCloseKey (hKey);
  50. }
  51. if (hUnicows == 0)
  52. {
  53. MessageBoxA (0, "Unicode wrapper not found", "My Company", MB_ICONSTOP | MB_OK);
  54. _exit (-1);
  55. }
  56. return hUnicows;
  57. }
  58. extern "C" HMODULE (__stdcall *_PfnLoadUnicows) (void) = &LoadUnicows;
  59. //
  60. // Wrappers for functions not handled by Godot
  61. //
  62. static BOOL __stdcall UserOleUIAddVerbMenuW(
  63. LPOLEOBJECT lpOleObj, //Pointer to the object
  64. LPCWSTR lpszShortType, //Pointer to the short name corresponding
  65. // to the object
  66. HMENU hMenu, //Handle to the menu to modify
  67. UINT uPos, //Position of the menu item.
  68. UINT uIDVerbMin, //Value at which to start the verbs
  69. UINT uIDVerbMax, //Maximum identifier value for object verbs
  70. BOOL bAddConvert, //Whether to add convert item
  71. UINT idConvert, //Value to use for the convert item
  72. HMENU FAR * lphMenu //Pointer to the cascading verb menu, if
  73. // created
  74. )
  75. {
  76. USES_CONVERSION;
  77. return OleUIAddVerbMenuA (lpOleObj,
  78. W2CA (lpszShortType),
  79. hMenu,
  80. uPos,
  81. uIDVerbMin,
  82. uIDVerbMax,
  83. bAddConvert,
  84. idConvert,
  85. lphMenu);
  86. }
  87. extern "C" FARPROC Unicows_OleUIAddVerbMenuW = (FARPROC)&UserOleUIAddVerbMenuW;
  88. static UINT __stdcall UserOleUIInsertObjectW (LPOLEUIINSERTOBJECTW lpouiiow)
  89. {
  90. UINT result = OLEUI_CANCEL;
  91. OLEUIINSERTOBJECTA ouiioa;
  92. ATLASSERT (sizeof (OLEUIINSERTOBJECTA) == sizeof (OLEUIINSERTOBJECTW));
  93. memcpy (&ouiioa, lpouiiow, sizeof (OLEUIINSERTOBJECTA));
  94. ATLASSERT (lpouiiow->lpszCaption == 0);
  95. ATLASSERT (lpouiiow->lpszTemplate == 0);
  96. ouiioa.lpszFile = (char *)alloca (ouiioa.cchFile + 1);
  97. ouiioa.lpszFile [0] = '\0';
  98. result = OleUIInsertObjectA(&ouiioa);
  99. if (result == OLEUI_SUCCESS)
  100. {
  101. USES_CONVERSION;
  102. wchar_t *lpszFile = lpouiiow->lpszFile;
  103. memcpy (lpouiiow, &ouiioa, sizeof (OLEUIINSERTOBJECTW));
  104. lpouiiow->lpszFile = lpszFile;
  105. wcscpy (lpouiiow->lpszFile, A2CW (ouiioa.lpszFile));
  106. }
  107. return result;
  108. }
  109. extern "C" FARPROC Unicows_OleUIInsertObjectW = (FARPROC)&UserOleUIInsertObjectW;