Microsoft KB Archive/198862

{|
 * width="100%"|

HOWTO: Use OemToBig5Str API on Windows NT

 * }

Q198862

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK)

-

SUMMARY
This article describes how to import and use the 16-bit Dynamic-Link Library (DLL) from the Traditional Chinese Windows 3.1 SDKE (Oem_big5.dll) to the Microsoft Windows NT environment.

The article also describes how to call the 32-bit function rather than the 16-bit function.

MORE INFORMATION
Developers want a translation function for Microsoft Windows 3.1 as well for as the 32-bit platforms. An application can be compiled on Visual C++ 1.52 on Windows 3.1, run the 16-bit .exe on the 32-bit platforms, and copy across the Oem_big5.dll file. On the 32-bit platforms, the function returns nonzero, which is believed to be success, but nothing is written into the target string.

This problem occurs only if the DLL was dynamically linked at build time; if it was statically linked then the function works.

The applications made a mistake by calling this function by using the C convention. The function is a PASCAL function, and the calling convention should be defined with the PASCAL calling convention. The following is an example of how to make the proper calling procedure.

The following line should be inserted at the beginning of the C file:

  #define      WINAPI          FAR PASCAL Then, the calling procedures resemble the following;

  WORD (WINAPI * lpfnProc) (int, WORD, LPSTR, LPSTR);

lpfnProc = (WORD (WINAPI *)(int, WORD, LPSTR, LPSTR))GetProcAddress(hInstance,"OemToBig5Str"); Applications can use the 32-bit function to convert OEM characters to Big5 characters by using the MultiByteToWideChar and WideCharToMultiByte functions. These functions use Unicode as a pivot point for translation, so applications must do the OEM-to-Unicode conversion first, then the Unicode-to-Big5 conversion.

Basically, applications must call the MultiByteToWideChar(CP_OEMCP,...) function to convert OEM characters to Unicode, then call the WideCharToMultibyte(CP_ACP,...) function to convert the Unicode characters to Big5 code (code page 950). (The CP_OEMCP stands for OEM code page and CP_ACP stands for the ANSI code page installed on the system.) So, if the system is Chinese Traditional, the CP_ACP is same as 950 (Big5). If the system is not Chinese, the Chinese code page/NLS file should be installed on the system, and the call appears as follows: WideCharToMultiByte(950,....). CP_ACP was substituted by 950. Because the system default code page is not 950, the code page 950 was explicitly used as the first parameter.

Additional query words:

Keywords : kb16bitonly kbIntl kbSDKPlatform kbDSupport

Issue type : kbhowto

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch