The Microsoft Layer for Unicode on Windows 9598ME Systems - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

The Microsoft Layer for Unicode on Windows 9598ME Systems

Description:

Once upon a time... Introducing the MS Layer for Unicode. Covered APIs and ... Not a layer over components (MLang, RichEdit, Uniscribe, CLR) 12 September 2002 ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 29
Provided by: downloadM
Category:

less

Transcript and Presenter's Notes

Title: The Microsoft Layer for Unicode on Windows 9598ME Systems


1
The Microsoft Layer for Unicode on Windows
95/98/ME Systems
  • Michael Kaplan
  • Cathy Wissink

Globalization Infrastructure Design and
Development Windows International Microsoft
2
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Covered APIs and functionality
  • Integration of the layer
  • What about Visual Studio.Net?
  • Where to get MSLU

3
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Covered APIs and functionality
  • Integration of the layer
  • What about Visual Studio.Net?
  • Where to get MSLU

4
Unicode and Windows
  • The WinNT Platform
  • Windows NT3.1/NT3.51/NT4/2000/XP/.NET
  • The Win9x Platform
  • Windows 95/98/ME

5
The old workarounds
  • Build two versions of the application
  • Multiple code bases or build types to maintain
  • Larger downloads/setups
  • Harder to isolate problems in code
  • Always do ANSI applications
  • No multilingual support
  • Poorer performance on NT platforms
  • No support for Unicode only languages
  • Use the 4/99 MSJ article from Microsoft
  • http//www.microsoft.com/msj/0499/multilangUnicode
    /multilangunicode.htm
  • A lot of work required!

6
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Integration of the layer
  • Covered APIs and functionality
  • What about Visual Studio.Net?
  • Where to get MSLU

7
Introducing MSLU
  • The MICROSOFT Layer for Unicode on Windows
    95/98/Me Systems
  • file name UnicoWS.dll
  • Allows you to write a single Unicode application
    for all platforms

8
Design goals
  • Allow developers to take advantage of the new
    languages on Windows 2000 and Windows XP without
    abandoning older platforms
  • Cannot slow down Unicode applications on
    WinNT/Win2K/WinXP
  • When possible, provide a consistent, identical
    Unicode subset of the Win32 API across all
    platforms

9
Other design goals
  • As small as possible
  • Dll is lt220kb
  • Has over 440 API wrappers
  • Has more than 50 "stub" wrappers
  • Frugal with resources
  • No registration required
  • No dependencies
  • No special file location requirement
  • No inherent "DLL hell" issues
  • Cannot be put in the system directory!

10
What the layer is not
  • Not intended to make Win9x multilingual
  • Not a rewrite of the Win9x platform
  • No NT-specific functionality added
  • No "Unicode-only" language support
  • No supplementary character support
  • No new international support
  • No new functionality added, at all
  • Not an "NT emulator" for Win9x!
  • Not a layer over components (MLang, RichEdit,
    Uniscribe, CLR)

11
Performance
  • No slowdown at all on WinNT/2K/XP
  • No extra DLL load
  • Native APIs called directly
  • Minimal slowdown on Win95/98/ME
  • Need time to convert strings to ANSI
  • For functions with out params, need to convert
    strings to Unicode
  • About the same as ANSI apps on NT

12
MSLU's custom loader
  • No Virginia, you cannot do a true static link
  • Your application statically links to the loader
  • The loader works in a similar way to the
    /DELAYLOAD functionality in VC
  • Supports the ability to override any API but get
    all the benefits of the loader!
  • No fear of failure
  • DLL not present
  • Low memory scenarios

13
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Covered APIs and functionality
  • Integration of the layer
  • What about Visual Studio.Net?
  • Where to get MSLU

14
Covered APIs and functionality - 1
  • Wraps almost every "W" Win32 API
  • The few that are not wrapped are ones that
    already support Unicode, such as the IME APIs
  • Stubs you can override are present for APIs not
    explicitly supported
  • Wraps several non "W" APIs when needed for
    Unicode support
  • Unicode support (e.g., IsWindowUnicode)
  • Consistent user messaging (e.g., CallWindowProcA)
  • Common, known issues (e.g., ExtTextOutW)
  • Includes full user messaging support

15
Covered APIs and functionality - 2
  • Works properly with the Unicode versions of MFC,
    ATL, and the CRT in both VS 6.0 and VS 7.0
  • Interoperability with other MSLU clients
  • in process
  • out of process
  • Interoperability with non-Unicode applications
  • Thread safety was a priority

16
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Covered APIs and functionality
  • Integration of the layer
  • What about Visual Studio.Net?
  • Where to get MSLU

17
Integration of the layer
  • Settings
  • /nodkernel32.lib /nod. unicows.lib
    kernel32.lib .
  • where . is all of these libs that you (or your
    component libs) use
  • 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 advapi32.lib

18
How the DLL is loaded
  • Setting an override
  • Add a function that you use to load the DLL
  • "Set the hook" by adding this line
  • extern "C" HMODULE (__stdcall _PfnLoadUnicows)
    (void) LoadUnicows
  • Good place to handle failure
  • Default behavior LoadLibrary!
  • Fallback to the shared location if you must (not
    preferred at all)
  • When all else fails, APIs fail gracefully

19
Overriding individual APIs
  • Add your function (using the same signature as
    the Win32 header files define)
  • "Set the hook" with this line of code
  • extern "C" FARPROC Unicows_ltapigtW
    (FARPROC)ltyour functiongt
  • Overriding "stubbed out" APIs
  • The PSDK has notes for every API, including any
    special issues, when needed

20
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Covered APIs and functionality
  • Integration of the layer
  • What about Visual Studio.Net?
  • Where to get MSLU

21
What about Visual Studio.Net?
  • VS.NET includes the Platform SDK unicows.lib is
    there!
  • CLR languages like VB.NET and C have their own
    delayload solution
  • PInvoke does not support calling different
    libraries on different platforms

22
C.NET syntax
  • using System
  • using System.Text
  • using System.Runtime.InteropServices
  • public class SystemAPI
  • DllImport("kernel32")
  • private static extern uint GetVersion()
  • DllImport("kernel32", EntryPoint"GetSystemDi
    rectoryW", CharSetCharSet.Unicode)
  • private static extern uint OsGetSystemDirector
    yW(StringBuilder lpBuf, uint uSize)
  • DllImport("unicows.dll", EntryPoint"GetSyste
    mDirectoryW", CharSetCharSet.Unicode)
  • private static extern uint MsluGetSystemDirect
    oryW(StringBuilder lpBuf, uint uSize)
  • public static uint GetSystemDirectory(StringBu
    ilder lpBuf, uint uSize)
  • if(GetVersion() lt 0x80000000)
  • return(OsGetSystemDirectoryW(lpBuf,
    uSize))
  • else

23
VB.NET syntax
  • Imports System
  • Imports System.Text
  • Imports System.Runtime.InteropServices
  • Public Class SystemAPI
  • Declare Function GetVersion Lib "kernel32" ()
    As Integer
  • Declare Unicode Function OsGetSystemDirectoryW
    _
  • Lib "kernel32" Alias "GetSystemDirectoryW" _
  • (ByVal lpBuf As StringBuilder, ByVal uSize
    As Integer) As Integer
  • Declare Unicode Function MsluGetSystemDirector
    yW _
  • Lib "unicows.dll" Alias "GetSystemDirectoryW"
    _
  • (ByVal lpBuf As StringBuilder, ByVal uSize
    As Integer) As Integer
  • Public Function GetSystemDirectory _
  • (ByVal lpBuf As StringBuilder, ByVal uSize
    As Integer) As Integer
  • If (GetVersion() gt H80000000) Then
  • GetSystemDirectory
    OsGetSystemDirectoryW(lpBuf, uSize)
  • Else

24
Agenda
  • Once upon a time...
  • Introducing the MS Layer for Unicode
  • Covered APIs and functionality
  • Integration of the layer
  • What about Visual Studio.Net?
  • Where to get MSLU

25
Where to get MSLU
  • the .LIB ships in the Platform SDK!
  • http//www.microsoft.com/msdownload/platformsdk/sd
    kupdate/
  • The DLL is a redistributable component
  • http//www.microsoft.com/msdownload/platformsdk/sd
    kupdate/psdkredist.htm

26
Resources
  • Announcement
  • http//www.microsoft.com/globaldev/Articles/mslu_a
    nnounce.asp
  • Article!
  • October 2001 MSDN Magazine (Wissink/Kaplan)
    http//msdn.microsoft.com/msdnmag/issues/01/10/
  • Newsgroups
  • microsoft.public.platformsdk.mslayerforunicode
  • microsoft.public.win32.programmer.international

27
Closing thoughts.
  • What does MSLU mean to Microsoft?
  • Why did it take so long to release MSLU?

28
Questions?
Write a Comment
User Comments (0)
About PowerShow.com