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.

70 lines
2.4 KiB

  1. #define ASSERT(x) if(!(x)) DebugBreak()
  2. #define SAFERELEASE(p) if (p) {(p)->Release(); p = NULL;} else ;
  3. #define SCHEDCDF 101
  4. #define ID_EXIT 40001
  5. #define ID_UPDATESCOPEALL 40002
  6. #define ID_UPDATESCOPEOFFLINE 40003
  7. #define ID_UPDATESCOPEONLINE 40004
  8. #define ID_UPDATEFRAMESCDF 40005
  9. #define ID_USEOTHERCDF 40006
  10. #define IDD_OTHER 102
  11. #define IDC_CDFNAME 1000
  12. #define IDC_STATIC -1
  13. #define REGSTR_PATH_SCHEDCDF TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\SchedCDF")
  14. #define REGSTR_VAL_CDFURLPATH TEXT("CDFUrlPath")
  15. #ifndef GUIDSTR_MAX
  16. // GUIDSTR_MAX is 39 and includes the terminating zero.
  17. // == Copied from OLE source code =================================
  18. // format for string form of GUID is (leading identifier ????)
  19. // ????{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}
  20. #define GUIDSTR_MAX (1+ 8 + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 12 + 1 + 1)
  21. // ================================================================
  22. #endif
  23. class TempBuffer {
  24. public:
  25. TempBuffer(ULONG cBytes) {
  26. m_pBuf = (cBytes <= 120) ? &m_szTmpBuf : GlobalAlloc(GPTR, cBytes);
  27. m_fGlobalAlloc = (cBytes > 120);
  28. }
  29. ~TempBuffer() {
  30. if (m_pBuf && m_fGlobalAlloc) GlobalFree(m_pBuf);
  31. }
  32. void *GetBuffer() {
  33. return m_pBuf;
  34. }
  35. private:
  36. void *m_pBuf;
  37. // we'll use this temp buffer for small cases.
  38. //
  39. char m_szTmpBuf[120];
  40. unsigned m_fGlobalAlloc:1;
  41. };
  42. #define MAKE_WIDEPTR_FROMANSI(ptrname, ansistr) \
  43. long __l##ptrname = (lstrlen(ansistr) + 1) * sizeof(WCHAR); \
  44. TempBuffer __TempBuffer##ptrname(__l##ptrname); \
  45. MultiByteToWideChar(CP_ACP, 0, ansistr, -1, (LPWSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname); \
  46. LPWSTR ptrname = (LPWSTR)__TempBuffer##ptrname.GetBuffer()
  47. //
  48. // Note: allocate lstrlenW(widestr) * 2 because its possible for a UNICODE
  49. // character to map to 2 ansi characters this is a quick guarantee that enough
  50. // space will be allocated.
  51. //
  52. #define MAKE_ANSIPTR_FROMWIDE(ptrname, widestr) \
  53. long __l##ptrname = (lstrlenW(widestr) + 1) * 2 * sizeof(char); \
  54. TempBuffer __TempBuffer##ptrname(__l##ptrname); \
  55. WideCharToMultiByte(CP_ACP, 0, widestr, -1, (LPSTR)__TempBuffer##ptrname.GetBuffer(), __l##ptrname, NULL, NULL); \
  56. LPSTR ptrname = (LPSTR)__TempBuffer##ptrname.GetBuffer()