home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / ansiapi.h < prev    next >
C/C++ Source or Header  |  1998-04-24  |  6KB  |  152 lines

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