Under Windows NT/2000/XP there is native support for Unicode applications. For Windows 95/98/ME there is an emulation layer called Microsoft Layer for Unicode or UNICOWS for short.
The layer consists of one .dll file, and one .lib file, which is linked to the program. The library contains loader code which checks the operating system and loads UNICOWS only if needed. Unfortunately the library is in COFF format and cannot directly be used in Borland C++ program. A partial solution is to create Borland-compatible import library from the .dll by using the IMPLIB utility. The drawback is that it will not contain the loader, so the UNICOWS layer will always be used, even when not needed. To use OWLNext with UNICOWS, some modification need to be done to the source, and the OWLNext must be build with UNICODE and USE_UNICOWS settings. Two different versions of the applications must be created, one using UNICODE OWLNext, to be executed under Windows NT/2000/XP, and another with UNICODE and UNICOWS, to be executed under Windows 95/98/ME. Modifications:
creationWindow->DefaultProc = (WNDPROC)GetProcAddress(
(HINSTANCE)GetModuleHandle(_T("USER32")), "DefWindowProcW");
with
# if defined(USE_UNICOWS)
creationWindow->DefaultProc = (WNDPROC)GetProcAddress(
(HINSTANCE)GetModuleHandle(_T("UNICOWS")), "DefWindowProcW");
# else
creationWindow->DefaultProc = (WNDPROC)GetProcAddress(
(HINSTANCE)GetModuleHandle(_T("USER32")), "DefWindowProcW");
# endif
#if defined(BI_PLAT_WIN32)
static const _TCHAR userStr[] = _T("USER32");
# if defined(UNICODE)
add the lines
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
static const _TCHAR MSLUStr[] = _T("UNICOWS");
TModule&
GetModuleMSLU()
{
static TModule MSLUModule(MSLUStr, ::GetModuleHandle(MSLUStr),false);
return MSLUModule;
}
#endif
HICON
TUser::LoadIcon(HINSTANCE p1, LPCTSTR p2)
{
static TModuleProc2<HICON, HINSTANCE, LPCTSTR>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
loadIcon(GetModuleMSLU(), LoadIconStr);
#else
loadIcon(GetModule(), LoadIconStr);
#endif
return loadIcon(p1, p2);
}
BOOL
TUser::GetClassInfo(HINSTANCE p1, LPCTSTR p2, LPWNDCLASS p3)
{
static TModuleProc3<BOOL, HINSTANCE, LPCTSTR, LPWNDCLASS>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
getClassInfo(GetModuleMSLU(), GetClassInfoStr);
#else
getClassInfo(GetModule(), GetClassInfoStr);
#endif
return getClassInfo(p1, p2, p3);
}
int
TUser::GetMenuString(HMENU p1, UINT p2, LPTSTR p3, int p4, UINT p5)
{
static TModuleProc5<int, HMENU, uint, LPTSTR, int, int>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
getMenuString(GetModuleMSLU(), GetMenuStringStr);
#else
getMenuString(GetModule(), GetMenuStringStr);
#endif
return getMenuString(p1, p2, p3, p4, p5);
}
BOOL
TVersion::GetFileVersionInfo(LPTSTR p1, DWORD p2, DWORD p3, LPVOID p4)
{
static TModuleProc4<BOOL,LPTSTR,DWORD,DWORD,LPVOID>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
getFileVersionInfo(GetModuleMSLU(), GetFileVersionInfoStr);
#else
getFileVersionInfo(GetModule(), GetFileVersionInfoStr);
#endif
return getFileVersionInfo(p1, p2, p3, p4);
}
DWORD
TVersion::GetFileVersionInfoSize(LPTSTR p1, LPDWORD p2)
{
static TModuleProc2<DWORD,LPTSTR,LPDWORD>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
getFileVersionInfoSize(GetModuleMSLU(), GetFileVersionInfoSizeStr);
#else
getFileVersionInfoSize(GetModule(), GetFileVersionInfoSizeStr);
#endif
return getFileVersionInfoSize(p1, p2);
}
BOOL
TVersion::VerQueryValue(const LPVOID p1,LPTSTR p2,LPVOID p3, uint far* p4)
{
static TModuleProc4<BOOL,const LPVOID,LPTSTR,LPVOID,uint far*>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
verQueryValue(GetModuleMSLU(), VerQueryValueStr);
#else
verQueryValue(GetModule(), VerQueryValueStr);
#endif
return verQueryValue(p1, p2, p3, p4);
}
DWORD
TVersion::VerLanguageName(DWORD p1, LPTSTR p2, DWORD p3)
{
static TModuleProc3<DWORD,DWORD,LPTSTR,DWORD>
#if defined(BI_PLAT_WIN32) && defined(UNICODE) && defined(USE_UNICOWS)
verLanguageName(GetModuleMSLU(), VerLanguageNameStr);
#else
verLanguageName(GetModule(), VerLanguageNameStr);
#endif
return verLanguageName(p1, p2, p3);
}