將字串轉譯成 OEM 定義的字元集。
Syntax
BOOL CharToOemA(
[in] LPCSTR pSrc,
[out] LPSTR pDst
);
Parameters
[in] pSrc
Type: LPCTSTR
要轉譯的 Null 終止字串。
[out] pDst
Type: LPSTR
接收已翻譯字串的目的地緩衝區。 If the CharToOem function is being used as an ANSI function, the string can be translated in place by setting the lpszDst parameter to the same address as the lpszSrc parameter. This cannot be done if CharToOem is being used as a wide-character function.
Return value
Type: BOOL
The return value is always nonzero except when you pass the same address to lpszSrc and lpszDst in the wide-character version of the function. In this case the function returns zero and GetLastError returns ERROR_INVALID_ADDRESS.
Remarks
Security Considerations
使用此函式不正確可能會危害程序的安全性。 For example, miscalculating the proper size of the lpszDst buffer, especially when the application is used in both ANSI and Unicode versions, can cause a buffer overflow. 如需詳細資訊,請參閱安全性考慮:國際功能和安全性考慮:Windows 使用者介面。
Note
winuser.h 標頭會將 CharToOem 定義為別名,根據 UNICODE 預處理器常數的定義,自動選取此函式的 ANSI 或 Unicode 版本。 混合使用編碼中性別名與非編碼中性的程序代碼,可能會導致編譯或運行時間錯誤不符。 如需詳細資訊,請參閱函式原型的
Requirements
| Requirement | Value |
|---|---|
| 最低支援的用戶端 | Windows 2000 Professional [僅限傳統型應用程式] |
| 支援的最低伺服器 | Windows 2000 Server [僅限傳統型應用程式] |
| Target Platform | Windows |
| Header | winuser.h (包括 Windows.h) |
| Library | User32.lib |
| DLL | User32.dll |
| API set | ext-ms-win-ntuser-chartranslation-l1-1-0 (在 Windows 8 中引進) |
See also
Conceptual
Reference