MSDN Home >  MSDN Library >  Windows Development >  Development Guides >  Microsoft Layer for Unicode on Windows 95/98/Me Systems >  Microsoft Layer for Unicode on Windows 95/98/Me Systems >  Using the Microsoft Layer for Unicode
 
Platform SDK: Microsoft Layer for Unicode on Windows 95/98/Me Systems

Compiling Your Application with the Microsoft Layer for Unicode

The Microsoft Layer for Unicode is available as a redistributable from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdkredist.htm. This download contains the UnicoWS.dll. The UnicoWS.lib is contained in the Platform SDK.

To compile an application that uses MSLU

  1. 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 the Microsoft Layer for Unicode 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.

  2. 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 libraries that the Microsoft Layer for Unicode uses explicitly: 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.
  3. 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, the Microsoft Layer for Unicode 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

  1. Add the following code to your application:
    #ifdef _cplusplus
    extern "C" {
    #endif
    extern FARPROC _PfnLoadUnicows = (FARPROC) &LoadUnicowsProc;
    #ifdef _cplusplus
    }
    #endif
  2. Define the LoadUnicowsProc function. This function is a user-defined callback function that takes no parameters. The loader calls it when needed to load the Microsoft Layer for Unicode. Note that LoadUnicowsProc is only called on Windows 95/98/Me. Also, LoadUnicowsProc is called before the DllMain PROCESS_ATTACH call and, for an .exe, before WinMain.
    HMODULE LoadUnicowsProc(void);
  3. 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 the Microsoft Layer for Unicode itself wraps. Doing so leads to a stack overflow because your callback calls the loader which calls your callback, and so forth.

 


©2005 Microsoft Corporation. All rights reserved. Terms of Use |Trademarks |Privacy Statement
Microsoft