home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / BOLEUI32.PAK / ANSIAPI.H next >
C/C++ Source or Header  |  1995-08-29  |  6KB  |  159 lines

  1. //
  2. /*
  3.  * ansiapi.h
  4.  * This file contains prototypes of ANSI version of OLE apis
  5.  * and mapping fooA to foo
  6.  */
  7.  
  8. #ifndef _ANSIAPI_INCL
  9. #define _ANSIAPI_INCL
  10.  
  11. #define UNICODEOLE32
  12.  
  13. #ifdef WIN32S
  14. #if !defined(UNICODEOLE32)
  15. #pragma message("Compiling for 32bit ANSI Ole!\n");
  16. #endif
  17. #endif
  18.  
  19. #define WASANSI() {                                                           \
  20.                    OutputDebugString("\n\r\t\tUnicode string was ANSI!\r\n"); \
  21.                    Assert(0);                                                 \
  22.                    _asm { int 3 }                                             \
  23.                   }
  24.  
  25.  
  26.  
  27. #ifndef UNICODEOLE32
  28.  
  29. #define W2A(w, a, cb)     lstrcpy (a, w)
  30. #define A2W(a, w, cb)     lstrcpy (w, a)
  31.  
  32. #define FREELOCALSTRING(p)
  33. #define MAKE_STR_LOCAL_COPYW2A(s, l)  l = s
  34. #define MAKE_STR_LOCAL_COPYA2W(s, l)  l = s
  35.  
  36. #define OLESTRCPY                lstrcpy
  37. #define OLESTRCAT                lstrcat
  38. #define OLESTRLEN                lstrlen
  39. #define OLESTRCMP                lstrcmp
  40. #define OLESTRCMPI               lstrcmpi
  41.  
  42. #define DeleteFile_AW            DeleteFile
  43. #define _lopen_AW                _lopen
  44. #define _lcreat_AW               _lcreat
  45. #define GlobalAddAtom_AW         GlobalAddAtom
  46. #define GlobalGetAtomName_AW     GlobalGetAtomName
  47. #define RegOpenKey_AW            RegOpenKey
  48.  
  49. #define CoLoadLibraryA   CoLoadLibrary
  50.  
  51. #define StringFromCLSID2A    StringFromCLSID2
  52. #define StringFromIID2A      StringFromIID2
  53. #define StringFromGUID2A     StringFromGUID2
  54. #define CLSIDFromProgIDA     CLSIDFromProgID
  55. #define CLSIDFromStringA     CLSIDFromString
  56. #define ProgIDFromCLSIDA     ProgIDFromCLSID
  57. #define StringFromCLSIDA     StringFromCLSID
  58.  
  59. #define UtDupStringA2W       UtDupString
  60.  
  61. // Storage APIs
  62. #define StgOpenStorageA      StgOpenStorage
  63.  
  64. // IPersistFile ansi translation
  65.  
  66. #define IPersistFile_LoadA(pf, file, mode) (pf)->Load(file, mode)
  67.  
  68. // IMoniker ansi translation
  69.  
  70. #define IMoniker_GetDisplayNameA(pm, p1, p2, p3) (pm)->GetDisplayName(p1,p2,p3)
  71.  
  72. #define CreateFileMonikerA   CreateFileMoniker
  73.  
  74. #else  // UNICODEOLE32
  75.  
  76.  
  77. #define W2A(w, a, cb)     WideCharToMultiByte(                              \
  78.                                                CP_ACP,                      \
  79.                                                0,                           \
  80.                                                w,                           \
  81.                                                -1,                          \
  82.                                                a,                           \
  83.                                                cb,                          \
  84.                                                NULL,                        \
  85.                                                NULL)
  86.  
  87. #define A2W(a, w, cb)     MultiByteToWideChar(                              \
  88.                                                CP_ACP,                      \
  89.                                                0,                           \
  90.                                                a,                           \
  91.                                                -1,                          \
  92.                                                w,                           \
  93.                                                cb)
  94.  
  95.  
  96. #define FREELOCALSTRING(p)      delete (p)
  97. #define MAKE_STR_LOCAL_COPYW2A(s, l)  {                                   \
  98.                                       l = UtDupStringW2A(s);              \
  99.                                       if (!l) {                           \
  100.                                          return ResultFromScode(S_OOM);   \
  101.                                       }                                   \
  102.                                    }
  103.  
  104. #define MAKE_STR_LOCAL_COPYA2W(s, l)  {                                   \
  105.                                       l = UtDupStringA2W(s);              \
  106.                                       if (!l) {                           \
  107.                                          return ResultFromScode(S_OOM);   \
  108.                                       }                                   \
  109.                                    }
  110.  
  111. #define OLESTRCPY                lstrcpyW
  112. #define OLESTRCAT                lstrcatW
  113. #define OLESTRLEN                lstrlenW
  114. #define OLESTRCMP                lstrcmpW
  115. #define OLESTRCMPI               lstrcmpiW
  116.  
  117. #define DeleteFile_AW            DeleteFileW
  118. #define _lopen_AW                _lopenW
  119. #define _lcreat_AW               _lcreatW
  120. #define GlobalAddAtom_AW         GlobalAddAtomW
  121. #define GlobalGetAtomName_AW     GlobalGetAtomNameW
  122. #define RegOpenKey_AW            RegOpenKeyW
  123.  
  124. STDAPI_(HINSTANCE) CoLoadLibraryA(LPSTR lpszLibName, BOOL bAutoFree);
  125.  
  126. #define StringFromCLSID2A(rclsid, lpsz, cbMax) \
  127.     StringFromGUID2A(rclsid, lpsz, cbMax)
  128.  
  129. #define StringFromIID2A(riid, lpsz, cbMax) \
  130.     StringFromGUID2A(riid, lpsz, cbMax)
  131.  
  132.  
  133. STDAPI_(int)  StringFromGUID2A(REFGUID rguid, LPSTR lpsz, int cbMax);
  134. STDAPI        CLSIDFromProgIDA(LPCSTR szProgID, LPCLSID pclsid);
  135. STDAPI        CLSIDFromStringA(LPSTR lpsz, LPCLSID lpclsid);
  136. STDAPI        StringFromCLSIDA(REFCLSID rclsid, LPSTR FAR* lplpsz);
  137. STDAPI        ProgIDFromCLSIDA (REFCLSID clsid, LPSTR FAR* lplpszProgID);
  138.  
  139. LPWSTR UtDupStringA2W(LPCSTR pSrc);
  140. LPSTR  UtDupStringW2A(LPCWSTR pSrc);
  141.  
  142. // Storage APIs
  143. STDAPI StgOpenStorageA(LPCSTR pwcsName,IStorage FAR *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage FAR * FAR *ppstgOpen);
  144.  
  145. // IPersistFile ansi translation
  146.  
  147. HRESULT IPersistFile_LoadA(LPPERSISTFILE pIPF, LPSTR szFile, DWORD dwMode);
  148.  
  149. // IMoniker ansi translation
  150.  
  151. HRESULT IMoniker_GetDisplayNameA(LPMONIKER pm, LPBC p1, LPMONIKER p2, LPSTR FAR *p3);
  152.  
  153. //OLEAPI CreateFileMonikerA ( LPSTR lpszPathName, LPMONIKER FAR * ppmk );
  154.  
  155. #endif // !UNICODEOLE32
  156.  
  157. #endif //  _ANSIAPI_INCL
  158.  
  159.