设为首页 加入收藏

TOP

对话方块(六十七)
2010-12-30 21:13:56 来源: 作者: 【 】 浏览:40857
Tags:对话 方块
Add an extra two bytes for zero termination.

iFileLength = GetFileSize (hFile, NULL) ;
pBuffer = malloc (iFileLength + 2) ;

// Read file and put terminating zeros at end.
ReadFile (hFile, pBuffer, iFileLength, &dwBytesRead, NULL) ;
CloseHandle (hFile) ;
pBuffer[iFileLength] = '\0' ;
pBuffer[iFileLength + 1] = '\0' ;

// Test to see if the text is Unicode
iUniTest = IS_TEXT_UNICODE_SIGNATURE | IS_TEXT_UNICODE_REVERSE_SIGNATURE ;
if (IsTextUnicode (pBuffer, iFileLength, &iUniTest))
{
pText = pBuffer + 2 ;
iFileLength -= 2 ;

if (iUniTest & IS_TEXT_UNICODE_REVERSE_SIGNATURE)
{
for (i = 0 ; i < iFileLength / 2 ; i++)
{
bySwap = ((BYTE *) pText) [2 * i] ;
((BYTE *) pText) [2 * i] = ((BYTE *) pText) [2 * i + 1] ;
((BYTE *) pText) [2 * i + 1] = bySwap ;
}
}

// Allocate memory for possibly converted string
pConv = malloc (iFileLength + 2) ;
// If the edit control is not Unicode, convert Unicode text to
// non-Unicode (i.e., in general, wide character).
#ifndef UNICODE
WideCharToMultiByte (CP_ACP, 0, (PWSTR) pText, -1, pConv,
iFileLength + 2, NULL, NULL) ;
// If the edit control is Unicode, just copy the string
#else
lstrcpy ((PT
首页 上一页 64 65 66 67 68 69 70 下一页 尾页 67/82/82
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇剪贴簿 下一篇功能表及其他资源

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: