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.

160 lines
2.2 KiB

  1. #ifndef __MAIN_HXX
  2. #define __MAIN_HXX
  3. //
  4. // System Includes
  5. //
  6. #define UNICODE
  7. #define _UNICODE
  8. #define INC_OLE2
  9. #include <windows.h>
  10. //
  11. // CRunTime Includes
  12. //
  13. #include <stdlib.h>
  14. #include <limits.h>
  15. #include <io.h>
  16. #include <stdio.h>
  17. #include <stddef.h>
  18. //
  19. // Public ADs includes
  20. //
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #include "activeds.h"
  25. #include "oledb.h"
  26. #include "oledberr.h"
  27. #ifdef __cplusplus
  28. }
  29. #endif
  30. #if (defined(BUILD_FOR_NT40))
  31. typedef DWORD DWORD_PTR;
  32. #endif
  33. #define NULL_TERMINATED 0
  34. //
  35. // ********* Useful macros
  36. //
  37. #define BAIL_ON_NULL(p) \
  38. if (!(p)) { \
  39. goto error; \
  40. }
  41. #define BAIL_ON_FAILURE(hr) \
  42. if (FAILED(hr)) { \
  43. goto error; \
  44. }
  45. #define FREE_INTERFACE(pInterface) \
  46. if (pInterface) { \
  47. pInterface->Release(); \
  48. pInterface=NULL; \
  49. }
  50. #define LOCAL_FREE(pMem) \
  51. if (pMem) { \
  52. LocalFree(pMem); \
  53. pMem = NULL; \
  54. }
  55. #define IMALLOC_FREE(pIMalloc, pMem) \
  56. if (pIMalloc) { \
  57. pIMalloc->Free(pMem); \
  58. pMem = NULL; \
  59. }
  60. #define FREE_STRING(pMem) \
  61. if (pMem) { \
  62. FreeADsStr(pMem); \
  63. pMem = NULL; \
  64. }
  65. //
  66. // Structure to hold the data from IRowset->GetData
  67. //
  68. typedef struct tagData {
  69. union {
  70. void *obValue;
  71. double obValue2;
  72. };
  73. ULONG obLength;
  74. ULONG status;
  75. } Data;
  76. //
  77. // External functions
  78. //
  79. HRESULT
  80. CreateAccessorHelper(
  81. IRowset *pIRowset,
  82. DBORDINAL cCol,
  83. DBCOLUMNINFO *prgColInfo,
  84. HACCESSOR *phAccessor,
  85. DBBINDSTATUS *pBindStatus
  86. );
  87. void
  88. PrintData(
  89. Data *prgData,
  90. DBORDINAL nCol,
  91. DBCOLUMNINFO *prgColInfo
  92. );
  93. int
  94. AnsiToUnicodeString(
  95. LPSTR pAnsi,
  96. LPWSTR pUnicode,
  97. DWORD StringLength
  98. );
  99. int
  100. UnicodeToAnsiString(
  101. LPWSTR pUnicode,
  102. LPSTR pAnsi,
  103. DWORD StringLength
  104. );
  105. LPWSTR
  106. AllocateUnicodeString(
  107. LPSTR pAnsiString
  108. );
  109. void
  110. FreeUnicodeString(
  111. LPWSTR pUnicodeString
  112. );
  113. void
  114. PrintUsage(
  115. void
  116. );
  117. HRESULT
  118. ProcessArgs(
  119. int argc,
  120. char * argv[]
  121. );
  122. #endif // __MAIN_HXX