Compiling Your Application with the Microsoft Layer for Unicode
2005-12-18 01:28
435 查看
Compiling Your Application with the Microsoft Layer for Unicode
The Microsoft Layer for Unicode (MSLU) is available as a redistributable fromhttp://www.microsoft.com/downloads/details.aspx?FamilyID=73BA7BD7-ED06-4F0D-80A4-2A7EEAEE17E2&displaylang=en. This download contains the UnicoWS.dll. The UnicoWS.lib is contained in the Platform SDK.
To compile an application that uses MSLU
Add the following two files to your project:
UnicoWS.dll -- the Microsoft Layer for Unicode DLL
UnicoWS.lib -- the LIB file to which you link
Note that MSLU does not automatically load from the $(WINDOWS) or $(WINSYS) directories. Thus, do not put UnicoWS.dll there unless you are running from a system process that is located there. Instead, keep the UnicoWS.dll in your application directory
and call
LoadLibrary yourself to ensure that you load the correct DLL.
Add the following to the link options for your application (note that these libraries are not separated by commas because that is how you add them to the link list):
First, add the following: /nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib
/nod:oledlg.lib /nod:sensapi.lib.
Then add UnicoWS.lib.
Finally, add the following libraries: Kernel32.lib Advapi32.lib User32.lib Gdi32.lib Shell32.lib Comdlg32.lib Version.lib Mpr.lib Rasapi32.lib Winmm.lib Winspool.lib Vfw32.lib Secur32.lib Oleacc.lib Oledlg.lib Sensapi.lib. In this step, omit any libraries
listed after Kernel32.lib whose APIs are not used in your application. However, if your application uses another component, such as MFC, ATL, or CRT, be sure to include any libraries on which the component depends.
Compile your application. If you are using side-by-side assemblies, you must define MICROSOFT_LAYER_FOR_UNICODE as 1.
When you follow these steps, MSLU loads itself by calling LoadLibrary. However, if you want to control the loading of the UnicoWS.lib you must perform the following additional steps. (These steps are also necessary if you are using side-by-side
assemblies.)
To control loading MSLU or use side-by-side assemblies
Add the following code to your application:
#ifdef _cplusplus extern "C" { #endif extern FARPROC _PfnLoadUnicows = (FARPROC) &LoadUnicowsProc; #ifdef _cplusplus } #endif
Define the LoadUnicowsProc function. This function is a user-defined callback function that takes no parameters. The loader calls it when needed to load MSLU. Note that LoadUnicowsProc is only called on Windows Me/98/95. Also, LoadUnicowsProc is called
before the
DllMain PROCESS_ATTACH call and, for an .exe, before WinMain.
HMODULE LoadUnicowsProc(void);
The following is a typical implementation of LoadUnicowsProc.
HMODULE LoadUnicowsProc(void) { return(LoadLibraryA("unicows.dll")); }
Note that you must call LoadLibraryA and all other Ansi APIs explicitly. This is because compiling as Unicode defines APIs like
LoadLibrary as LoadLibraryW. For more information, see
Conventions for Function Prototypes.
If you load the Unicows.lib in this manner, you must never call any of the APIs that MSLU itself wraps. Doing so leads to a stack overflow because your callback calls the loader which calls your callback, and so on.
相关文章推荐
- # Please enter the commit message for your changes. Lines starting # with '#' will be ignored
- 刚用SpringBoot搭建的项目,To display the auto-configuration report re-run your application with 'debug' enab
- This file is based on the Microsoft Data Access Application Block for .NET
- 8.1 Details Your app does not comply with the Guidelines for Using Apple's Trademarks and Copyrights
- 44.Your database is functional with a peak load for the last one hour. You want to preserve the perf
- [转]Using the Microsoft Connector for Oracle by Attunity with SQL Server 2008 Integration Services
- - Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>, as they will not be parsed.
- Developing IOS Application with Delphi Xe4 .only for play the toy?
- Profile your application in the simulator with 'Zombies' Instrument.
- Unify the Role-Based Security Models for Enterprise and Application Domains with .NET
- Create your first HTML-based AIR application with the AIR SDK
- Implement a Data Access Layer for Your App with ADO.NET
- Install multiple instances of Reporting Services on the same computer (for use with Microsoft Dynami
- Using Clang as a Library----Choosing the Right Interface for Your Application---翻译
- Ioc:The basic pattern for integrating Autofac into your application
- Building Solutions with the Microsoft .NET Compact Framework: Architecture and Best Practices for Mo
- [React] Theme your application with styled-components and "ThemeProvider"
- Build a .NET Application on the Oracle Database with Microsoft Visual Studio 2010
- 《Microsoft PowerPivot for Excel 2010: Give Your Data Meaning》:PowerPivot入门级读物
- Android Essentials: Submitting Your Application to the Android Market