ANSIAPI.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:6k
源码类别:

Windows编程

开发平台:

Visual C++

  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. #define UNICODEOLE32
  9. #ifdef WIN32S
  10. #if !defined(UNICODEOLE32)
  11. #pragma message("Compiling for 32bit ANSI Ole!n");
  12. #endif
  13. #endif
  14. #define WASANSI() {                                                           
  15.                    OutputDebugString("nrttUnicode string was ANSI!rn"); 
  16.                    Assert(0);                                                 
  17.                    _asm { int 3 }                                             
  18.                   }
  19. #ifndef UNICODEOLE32
  20. #define W2A(w, a, cb)     lstrcpy (a, w)
  21. #define A2W(a, w, cb)     lstrcpy (w, a)
  22. #define FREELOCALSTRING(p)
  23. #define MAKE_STR_LOCAL_COPYW2A(s, l)  l = s
  24. #define MAKE_STR_LOCAL_COPYA2W(s, l)  l = s
  25. #define OLESTRCPY                lstrcpy
  26. #define OLESTRCAT                lstrcat
  27. #define OLESTRLEN                lstrlen
  28. #define OLESTRCMP                lstrcmp
  29. #define DeleteFile_AW            DeleteFile
  30. #define _lopen_AW                _lopen
  31. #define _lcreat_AW               _lcreat
  32. #define GlobalAddAtom_AW         GlobalAddAtom
  33. #define GlobalGetAtomName_AW     GlobalGetAtomName
  34. #define RegOpenKey_AW            RegOpenKey
  35. #define CoLoadLibraryA   CoLoadLibrary
  36. #define StringFromCLSID2A    StringFromCLSID2
  37. #define StringFromIID2A      StringFromIID2
  38. #define StringFromGUID2A     StringFromGUID2
  39. #define CLSIDFromProgIDA     CLSIDFromProgID
  40. #define CLSIDFromStringA     CLSIDFromString
  41. #define ProgIDFromCLSIDA     ProgIDFromCLSID
  42. #define StringFromCLSIDA     StringFromCLSID
  43. #define UtDupStringA2W       UtDupString
  44. // Storage APIs
  45. #define StgOpenStorageA      StgOpenStorage
  46. // IPersistFile ansi translation
  47. #define IPersistFile_LoadA(pf, file, mode) (pf)->Load(file, mode)
  48. // IMoniker ansi translation
  49. #define IMoniker_GetDisplayNameA(pm, p1, p2, p3) (pm)->GetDisplayName(p1,p2,p3)
  50. #define CreateFileMonikerA   CreateFileMoniker
  51. #else  // UNICODEOLE32
  52. #define W2A(w, a, cb)     WideCharToMultiByte(                              
  53.                                                CP_ACP,                      
  54.                                                0,                           
  55.                                                w,                           
  56.                                                -1,                          
  57.                                                a,                           
  58.                                                cb,                          
  59.                                                NULL,                        
  60.                                                NULL)
  61. #define A2W(a, w, cb)     MultiByteToWideChar(                              
  62.                                                CP_ACP,                      
  63.                                                0,                           
  64.                                                a,                           
  65.                                                -1,                          
  66.                                                w,                           
  67.                                                cb)
  68. #define FREELOCALSTRING(p)      delete (p)
  69. #define MAKE_STR_LOCAL_COPYW2A(s, l)  {                                   
  70.                                       l = UtDupStringW2A(s);              
  71.                                       if (!l) {                           
  72.                                          return ResultFromScode(S_OOM);   
  73.                                       }                                   
  74.                                    }
  75. #define MAKE_STR_LOCAL_COPYA2W(s, l)  {                                   
  76.                                       l = UtDupStringA2W(s);              
  77.                                       if (!l) {                           
  78.                                          return ResultFromScode(S_OOM);   
  79.                                       }                                   
  80.                                    }
  81. #define OLESTRCPY                wcscpy
  82. #define OLESTRCAT                wcscat
  83. #define OLESTRLEN                wcslen
  84. #define OLESTRCMP                wcscmp
  85. #define DeleteFile_AW            DeleteFileW
  86. #define _lopen_AW                _lopenW
  87. #define _lcreat_AW               _lcreatW
  88. #define GlobalAddAtom_AW         GlobalAddAtomW
  89. #define GlobalGetAtomName_AW     GlobalGetAtomNameW
  90. #define RegOpenKey_AW            RegOpenKeyW
  91. //STDAPI_(HINSTANCE) CoLoadLibraryA(LPSTR lpszLibName, BOOL bAutoFree);
  92. #define StringFromCLSID2A(rclsid, lpsz, cbMax) 
  93.     StringFromGUID2A(rclsid, lpsz, cbMax)
  94. #define StringFromIID2A(riid, lpsz, cbMax) 
  95.     StringFromGUID2A(riid, lpsz, cbMax)
  96. //STDAPI_(int)  StringFromGUID2A(REFGUID rguid, LPSTR lpsz, int cbMax);
  97. //STDAPI        CLSIDFromProgIDA(LPCSTR szProgID, LPCLSID pclsid);
  98. //STDAPI        CLSIDFromStringA(LPSTR lpsz, LPCLSID lpclsid);
  99. //STDAPI        StringFromCLSIDA(REFCLSID rclsid, LPSTR FAR* lplpsz);
  100. //STDAPI        ProgIDFromCLSIDA (REFCLSID clsid, LPSTR FAR* lplpszProgID);
  101. //LPWSTR UtDupStringA2W(LPCSTR pSrc);
  102. //LPSTR  UtDupStringW2A(LPCWSTR pSrc);
  103. // Storage APIs
  104. //STDAPI StgOpenStorageA(LPCSTR pwcsName,IStorage FAR *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage FAR * FAR *ppstgOpen);
  105. // IPersistFile ansi translation
  106. //HRESULT IPersistFile_LoadA(LPPERSISTFILE pIPF, LPSTR szFile, DWORD dwMode);
  107. // IMoniker ansi translation
  108. //HRESULT IMoniker_GetDisplayNameA(LPMONIKER pm, LPBC p1, LPMONIKER p2, LPSTR FAR *p3);
  109. //OLEAPI CreateFileMonikerA ( LPSTR lpszPathName, LPMONIKER FAR * ppmk );
  110. #endif // !UNICODEOLE32
  111. #endif //  _ANSIAPI_INCL