Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CS_CSSYS_WIN32_WINTOOLS_H__
00020 #define __CS_CSSYS_WIN32_WINTOOLS_H__
00021
00026 #include "csextern.h"
00027 #include "csutil/csunicode.h"
00028 #include "csutil/util.h"
00029 #include <winnls.h>
00030 #include "sanity.inc"
00031
00041 static inline wchar_t* cswinAnsiToWide (const char* ansi,
00042 UINT codePage = CP_ACP)
00043 {
00044 int bufsize;
00045 WCHAR* buf;
00046
00047 bufsize = MultiByteToWideChar (codePage,
00048 MB_PRECOMPOSED, ansi, -1, 0, 0);
00049 buf = new WCHAR[bufsize];
00050 MultiByteToWideChar (codePage,
00051 MB_PRECOMPOSED, ansi, -1, buf, bufsize);
00052
00053 return buf;
00054 }
00055
00065 static inline char* cswinWideToAnsi (const wchar_t* wide,
00066 UINT codePage = CP_ACP)
00067 {
00068 int bufsize;
00069 char* buf;
00070
00071 bufsize = WideCharToMultiByte (codePage,
00072 WC_COMPOSITECHECK, wide, -1, 0, 0, 0, 0);
00073 buf = new char[bufsize];
00074 WideCharToMultiByte (codePage,
00075 WC_COMPOSITECHECK, wide, -1, buf, bufsize, 0, 0);
00076
00077 return buf;
00078 }
00079
00093 struct CS_CRYSTALSPACE_EXPORT cswinWtoA
00094 {
00095 private:
00096 char* s;
00097 public:
00099 cswinWtoA (const wchar_t* ws)
00100 { s = cswinWideToAnsi (ws); }
00102 ~cswinWtoA ()
00103 { delete[] s; }
00105 operator const char* () const
00106 { return s; }
00107 };
00108
00118 struct CS_CRYSTALSPACE_EXPORT cswinCtoA
00119 {
00120 private:
00121 char* s;
00122 public:
00124 cswinCtoA (const char* ws, UINT codePage = CP_ACP)
00125 {
00126 s = cswinWideToAnsi (csCtoW (ws), codePage);
00127 }
00129 ~cswinCtoA ()
00130 { delete[] s; }
00132 operator const char* () const
00133 { return s; }
00134 };
00135
00147 extern CS_CRYSTALSPACE_EXPORT char* cswinGetErrorMessage (HRESULT code);
00158 extern CS_CRYSTALSPACE_EXPORT wchar_t* cswinGetErrorMessageW (HRESULT code);
00159
00161 enum cswinWindowsVersion
00162 {
00164 cswinWin9x = 30,
00166 cswinWinNT = 40,
00168 cswinWin2K = 50,
00170 cswinWinXP = 51,
00172 cswinWin2003 = 52,
00174 cswinWinVista = 60
00175 };
00176
00188 extern CS_CRYSTALSPACE_EXPORT bool cswinIsWinNT (cswinWindowsVersion* version = 0);
00189
00190 #endif // __CS_CSSYS_WIN32_WINTOOLS_H__