/************************************************* * basefunc.c * * * * Copyright (C) 1995-1999 Microsoft Inc. * * * *************************************************/ #include #include #include #include #include #include #include #include #include "conv.h" #include "propshet.h" #define MAX_VALUE_NAME 256 #ifdef UNICODE TCHAR szCaption[] = {0x8F93, 0x5165, 0x6CD5, 0x751F, 0x6210, 0x5668, 0x0000}; #else BYTE szCaption[] = "输入法生成器" #endif /**** delete all spaces of string *****/ void DelSpace(LPTSTR szStr) { TCHAR szStr1[512]; int len,count=0; register int i=0; len = lstrlen(szStr); do { if(szStr[i] == 32||szStr[i] == TEXT('\t')) continue; szStr1[count] = szStr[i]; if(szStr1[count] >= TEXT('A') && szStr1[count] <= TEXT('Z')) szStr1[count] |= 0x20; count ++; } while(i++ 0x100) nDBCS++; else break; } #else len = lstrlen(szInputStr); for(i=0; i (UCHAR)0x80) && ((UCHAR)szInputStr[i+1] >= 0x40 && (UCHAR)szInputStr[i+1] <= (UCHAR)0xfe && (UCHAR)szInputStr[i+1] != (UCHAR)0x7f) ) nDBCS += 2; else break; } #endif if(nDBCS == 0) { /* LoadString(NULL, IDS_NOTEXISTDBCS, szTmpStr, sizeof(szTmpStr)); wsprintf(szStr,"\'%s%lu)",szTmpStr,dwLineNo); FatalMessage(hWnd,szStr);*/ return -1; } lstrncpy(szDBCS,nDBCS,szInputStr); szDBCS[nDBCS] = 0; lstrcpy(szStr,&szInputStr[nDBCS]); trim(szStr); len = lstrlen(szStr); if(len > 0) { for(i = 0; i wMaxCodes) { LoadString(NULL, IDS_DBCSCODELEN, szTmpStr, sizeof(szTmpStr)/sizeof(TCHAR)); #ifdef UNICODE { TCHAR UniTmp[] = {0x884C, 0x0000}; wsprintf(szStr, TEXT("\'%ws\'%ws%d!(%ws:%lu)"), szDBCS,szTmpStr,wMaxCodes,UniTmp,dwLineNo); } #else wsprintf(szStr,"\'%s\'%s%d!(行:%lu)", szDBCS,szTmpStr,wMaxCodes,dwLineNo); #endif FatalMessage(hWnd,szStr); return FALSE; //szStr[wMaxCodes] = 0; } lstrncpy(szCodeStr,nCodes, szStr); szCodeStr[nCodes] = 0; DelSpace(szCodeStr); lstrcpy(szCreateStr,&szStr[nCodes]); szCreateStr[MAXCODELEN] = 0; DelSpace(szCreateStr); return TRUE; } /**** delete spaces of string's head and tail *****/ void trim(LPTSTR szStr) { register int i=0; UINT len ; while(szStr[i] == 32 || szStr[i] == TEXT('\t')) i++; lstrcpy(szStr,&szStr[i]); len = lstrlen(szStr); if(len == 0) return; i = 1; while(szStr[len-i] == 32 || szStr[len-i] == TEXT('\r') || szStr[len-i] == TEXT('\n') || szStr[len-i] == TEXT('\t') || szStr[len-i] == 0) i++; szStr[len-i+1] = 0; len = lstrlen(szStr); for(i=0; i<(int)len; i++) { if(szStr[i] > 0x100) continue; if(szStr[i] >= TEXT('A') && szStr[i] <= TEXT('Z')) szStr[i] |= 0x20; } } void fnsplit(LPCTSTR szFullPath, LPTSTR szFileName) { LPTSTR lpString; #ifdef UNICODE if((lpString=wcsrchr(szFullPath,TEXT('\\')))!=NULL) #else if((lpString=strrchr(szFullPath,TEXT('\\')))!=NULL) #endif lstrcpy(szFileName,lpString+1); else lstrcpy(szFileName,szFullPath); } BOOL ErrMessage(HANDLE hWnd,LPTSTR lpText) { int RetValue; RetValue = MessageBox(hWnd, lpText, szCaption, MB_ICONEXCLAMATION|MB_YESNO|MB_DEFBUTTON2); if(RetValue == IDYES) return TRUE; else return FALSE; } VOID WarnMessage(HANDLE hWnd,LPTSTR lpText) { MessageBox(hWnd,lpText,szCaption,MB_ICONEXCLAMATION|MB_OK); } VOID InfoMessage(HANDLE hWnd,LPTSTR lpText) { MessageBox(hWnd,lpText,szCaption,MB_ICONINFORMATION|MB_OK); } VOID FatalMessage(HANDLE hWnd,LPTSTR lpText) { MessageBox(hWnd,lpText,szCaption,MB_ICONSTOP|MB_OK); } void lstrncpy(LPTSTR lpDest,int nCount,LPTSTR lpSrc) { register int i; BOOL bEnd = FALSE; for(i=0; i right ) return; i=(int)left; j=(int)right; mid = (i+j)/2; MidWord = item[mid]; do { while( i < (int)right) { k = lstrcmpi(MidWord.szCode,item[i].szCode); if ( ( k > 0 ) || ( k==0 && i< mid ) ) i++; else break; } while( j > (int)left ) { k=lstrcmpi(MidWord.szCode,item[j].szCode); if ( ( k < 0 ) || (k == 0 && j > mid) ) j--; else break; } if(i <= j) { SwapWord = item[i]; item[i] = item[j]; item[j] = SwapWord; i++; j--; } } while(i <= j); if((int)left < j) qSort(item,left,j); if(i < (int)right) qSort(item,i,right); } /******** Quick sort char function ********/ void qSortChar(LPTSTR item, DWORD left,DWORD right) { int i,j,mid; TCHAR MidChar,SwapChar; if ( left > right ) return ; i=(int)left; j=(int)right; mid = (i+j)/2; MidChar = item[mid]; do { while( ( MidChar > item[i] && i < (int)right) ||(MidChar == item[i] && i != mid) ) i++; while( (MidChar (int)left) ||(MidChar == item[j] && j!=mid) ) j--; if(i <= j) { SwapChar = item[i]; item[i] = item[j]; item[j] = SwapChar; i++; j--; } } while(i <= j); if((int)left < j) qSortChar(item,left,j); if(i < (int)right) qSortChar(item,i,right); } DWORD EncodeToNo(LPTSTR szDBCS) { WORD wCode; LPENCODEAREA lpEncode; DWORD dwNo = 0xffffffff, i; lpEncode = (LPENCODEAREA) GlobalLock(hEncode); #ifdef UNICODE wCode = szDBCS[0]; #else wCode = (WORD)((UCHAR)szDBCS[0])*256 + (WORD)(UCHAR)szDBCS[1]; #endif for( i = NUMENCODEAREA -1; (long)i>=0; i--) { if(wCode >= lpEncode[i].StartEncode) { dwNo = lpEncode[i].PreCount; dwNo += wCode - lpEncode[i].StartEncode; break; } } if(dwNo > NUM_OF_ENCODE) dwNo = 0xffffffff; GlobalUnlock(hEncode); return dwNo; } DWORD EncodeToGBNo(UCHAR szDBCS[3]) { DWORD dwNo; if(szDBCS[0] < 0xa1 || szDBCS[1] < 0xa1 || szDBCS[1] > 0xfe) { dwNo = 0xffffffff; return dwNo; } dwNo = (DWORD)(szDBCS[0]-0xa0-16) ; dwNo = dwNo * 94 + (DWORD)(szDBCS[1]-0xa0-1) - ((dwNo > 39)?5:0); return dwNo; } void NoToEncode(DWORD dwNo,LPBYTE szDBCS, DWORD dwNumArea, LPENCODEAREA lpEncode) { DWORD Value,i; for( i =dwNumArea-1; (long)i>=0; i--) { if(dwNo >= lpEncode[i].PreCount) { Value = dwNo-lpEncode[i].PreCount; Value += lpEncode[i].StartEncode; #ifdef UNICODE szDBCS[0] = (UCHAR)(Value&0xff); szDBCS[1] = (UCHAR)((Value>>8)&0xff); #else szDBCS[0] = (UCHAR)((Value>>8)&0xff); szDBCS[1] = (UCHAR)(Value&0xff); #endif break; } } } void NoToGB2312Code(DWORD dwNo,LPBYTE szDBCS, DWORD dwNumArea) { DWORD Value; szDBCS[0] = 0; szDBCS[1] = 0; if(dwNo > GB2312WORDNUM) return; Value = dwNo + ((dwNo >= 3755)?5:0); szDBCS[0] = (BYTE)(Value/94 +16 +0xa0); szDBCS[1] = (BYTE)(Value%94 + 0xa1); } void RuleToText(LPRULE lpRule, LPTSTR szStr) { DWORD dwTemp; int nCount=0,i; szStr[0]=TEXT('c'); dwTemp = lpRule->byLogicOpra; szStr[1]=(dwTemp==0)?TEXT('e'):(dwTemp==1)?TEXT('a'):TEXT('b'); dwTemp = lpRule->byLength; szStr[2]=(dwTemp<10)?TEXT('0')+(TCHAR)dwTemp:TEXT('a')+(TCHAR)dwTemp-10; szStr[3]=TEXT('='); nCount = lpRule->wNumCodeUnits; for(i=0; i< nCount; i++) { dwTemp = lpRule->CodeUnit[i].dwDirectMode; szStr[4+i*4] = (dwTemp==0)?TEXT('p'):TEXT('n'); dwTemp = lpRule->CodeUnit[i].wDBCSPosition; szStr[4+i*4+1] = (dwTemp<10)?TEXT('0')+(TCHAR)dwTemp:TEXT('a')+(TCHAR)dwTemp-10; dwTemp = lpRule->CodeUnit[i].wCodePosition; szStr[4+i*4+2] = (dwTemp<10)?TEXT('0')+(TCHAR)dwTemp:TEXT('a')+(TCHAR)dwTemp-10; szStr[4+i*4+3] = TEXT('+'); } szStr[4+4*nCount-1] = 0; lstrcat(szStr,TEXT("\r\n")); } void MoveFileBlock(HANDLE hFile,DWORD dwOffset,DWORD dwSize, DWORD dwDirect) //** if (dwDirect==0) move block to file begin, else move to file end { BYTE Buffer[MAXREADBUFFER]; static BYTE space[MAXREADBUFFER]; DWORD i,dwReadBytes,dwFilePtr; SetFilePointer(hFile,dwOffset,0,FILE_BEGIN); if(dwDirect == 0) { do { ReadFile(hFile,Buffer,sizeof(Buffer),&dwReadBytes,NULL); SetFilePointer(hFile, (0-dwReadBytes-dwSize),0,FILE_CURRENT); WriteFile(hFile,Buffer,dwReadBytes,&dwReadBytes,NULL); SetFilePointer(hFile, dwSize,0,FILE_CURRENT); }while(dwReadBytes == MAXREADBUFFER); SetFilePointer(hFile, 0-dwSize,0,FILE_CURRENT); for(i=0;i dwOffset) { if(dwFilePtr > dwOffset+MAXREADBUFFER) dwReadBytes = MAXREADBUFFER; else dwReadBytes = dwFilePtr - dwOffset; dwFilePtr = SetFilePointer(hFile,(0-dwReadBytes),0,FILE_CURRENT); ReadFile(hFile,Buffer,dwReadBytes,&dwReadBytes,NULL); SetFilePointer(hFile, (dwSize-dwReadBytes),0,FILE_CURRENT); WriteFile(hFile,Buffer,dwReadBytes,&dwReadBytes,NULL); SetFilePointer(hFile, (0-dwSize-dwReadBytes),0,FILE_CURRENT); } } } BOOL Copy_File(LPCTSTR SrcFile,LPCTSTR DestFile) { BYTE Buffer[MAXREADBUFFER]; HANDLE hSrcFile, hDestFile; DWORD dwReadBytes; hSrcFile = Create_File(GetFocus(),(LPTSTR)SrcFile,GENERIC_READ,OPEN_EXISTING); hDestFile = CreateFile((LPTSTR)DestFile,GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL); if(hSrcFile == (HANDLE)-1) return FALSE; if(hDestFile == (HANDLE)-1) { CloseHandle(hSrcFile); return FALSE; } SetFilePointer(hSrcFile,0,0,FILE_BEGIN); do { ReadFile(hSrcFile,Buffer,sizeof(Buffer),&dwReadBytes,NULL); WriteFile(hDestFile,Buffer,dwReadBytes,&dwReadBytes,NULL); }while(dwReadBytes == MAXREADBUFFER); CloseHandle(hSrcFile); CloseHandle(hDestFile); return TRUE; } /**************************************************************************** * * FUNCTION: CheckCrtData(HANDLE hWnd, * LPCREATEWORD lpCreateWords, * LPENCODEAREA lpEncode, * DWORD dwMaxCodes) * * PURPOSE: check whether create word data is entired or not. * * RETURN VALUES: * TRUE or FALSE. * * HISTORY: * * ****************************************************************************/ BOOL CheckCrtData(HANDLE hWnd, LPCREATEWORD lpCreateWords, LPENCODEAREA lpEncode, DWORD dwMaxCodes) { DWORD i; TCHAR szDBCS[3],szCreate[13]; TCHAR szTemp[128],szTmpStr[128]; BOOL bErr = FALSE; #ifdef UNICODE //check CJK Unified Ideograph subset only for (i=0x250; i< 0x250+NUM_OF_CJK_CHINESE; i++) { #else for (i=0; i< NUM_OF_ENCODE ; i++) { #endif lstrncpy(szCreate,dwMaxCodes,&lpCreateWords[i*dwMaxCodes]); szCreate[dwMaxCodes] = 0; if(lstrlen(szCreate) == 0) { NoToEncode(i, (LPBYTE)szDBCS, NUMENCODEAREA, lpEncode); //NoToGB2312Code(i,szDBCS,NUMENCODEAREA); szDBCS[1] =0; //#62550 LoadString(NULL, IDS_WORDNOTEXIST, szTmpStr, sizeof(szTmpStr)/sizeof(TCHAR)); wsprintf(szTemp,TEXT("\'%s\' %s"),szDBCS,szTmpStr); if(ErrMessage(hWnd,szTemp)) return FALSE; bErr = TRUE; } } return (!bErr) ; } void DispInfo(HANDLE hWnd,WORD wStrID) { TCHAR text[80]; LoadString(NULL,wStrID,text,sizeof(text)/sizeof(TCHAR)); SetDlgItemText(hWnd,TM_TOTALINFO,text); SetDlgItemText(hWnd,TM_TOTAL,TEXT("")); SetDlgItemText(hWnd,TM_TOTALNUM,TEXT("")); SetDlgItemText(hWnd,TM_CONVINFO,TEXT("")); SetDlgItemText(hWnd,TM_CONVNUM,TEXT("")); InvalidateRect(hWnd,NULL,FALSE); } BOOL WriteEMBToFile(LPCTSTR path_name,LPEMB_Head EMB_Table) { HANDLE hFile; DWORD byte_t_write; TCHAR szStr[256],szStr1[256]; hFile = CreateFile(path_name,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,0,NULL); if(hFile==INVALID_HANDLE_VALUE) { LoadString(NULL,IDS_FILEOPEN,szStr, sizeof(szStr)/sizeof(TCHAR)); wsprintf(szStr1,TEXT("\'%s\' %s\n"),path_name,szStr); FatalMessage(GetFocus(),szStr1); return(0); } WriteFile(hFile,&EMB_Count,sizeof(EMB_Count),&byte_t_write,NULL); WriteFile(hFile,EMB_Table,EMB_Count*sizeof(EMB_Head), &byte_t_write, NULL); GlobalUnlock(HmemEMB_Table); SetEndOfFile(hFile); CloseHandle(hFile); return (1); } BOOL ReadEMBFromFile(LPCTSTR path_name, LPEMB_Head EMB_Table) { HANDLE hFile; DWORD byte_t_write; hFile = CreateFile(path_name,GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_ALWAYS,0,NULL); if(hFile==INVALID_HANDLE_VALUE) { ProcessError(ERR_IMEUSE, GetFocus(), ERR); return FALSE; } /* if(hFile == INVALID_HANDLE_VALUE) { ProcessError(ERR_FILENOTOPEN,GetFocus(),ERR); return(0); }*/ SetFilePointer(hFile,0,0,FILE_BEGIN); EMB_Count = 0; ReadFile(hFile,&EMB_Count,sizeof(EMB_Count),&byte_t_write,NULL); if(EMB_Count > 1000) { CloseHandle(hFile); return (0); } HmemEMB_Table = GlobalAlloc(GMEM_DISCARDABLE,(EMB_Count+1)*sizeof(EMB_Head)); EMB_Table = GlobalLock(HmemEMB_Table); ReadFile(hFile,EMB_Table,EMB_Count*sizeof(EMB_Head), &byte_t_write, NULL); GlobalUnlock(HmemEMB_Table); SetEndOfFile(hFile); CloseHandle(hFile); return (1); } int AddZCItem(LPCTSTR path_name,LPEMB_Head EMB_Table,LPTSTR wai_code,LPTSTR cCharStr) { //string must end by '\0' int i; if(EMB_Count >= 1000) return FALSE; for(i=0; i= 1000) { ProcessError(ERR_TOOMANYUSERWORD,hWnd,WARNING); CloseHandle(hFile); SetCursor (LoadCursor (NULL, IDC_ARROW)); return FALSE; } szStr[0]=0; } else { szStr[j]=Buffer[i]; j++; } } /*** for (i=0;...) ****/ if(j) SetFilePointer(hFile,0-j,0,FILE_CURRENT); if(dwReadBytes*sizeof(TCHAR) < MAXREADBUFFER) break; }; CloseHandle(hFile); SetCursor (LoadCursor (NULL, IDC_ARROW)); return TRUE; } int CheckUserWord(HWND hWnd,LPTSTR szUserWord,WORD wMaxCodes) { int retValue; TCHAR szTemp[256]; TCHAR szDBCS[256],szCode[30]; retValue = ParseDBCSstr(hWnd,szUserWord, szDBCS,szCode,szTemp,wMaxCodes); if(retValue != TRUE) return retValue; if(lstrlen(szDBCS) == 0 || lstrlen(szCode) == 0) return -1; else return retValue; } BOOL CheckUserDBCS(HWND hWnd,LPTSTR szDBCS) { int nDBCS=0,i; static TCHAR szTmpStr[256],szTemp[256]; nDBCS=lstrlen(szDBCS); if(nDBCS == 0) return FALSE; #ifndef UNICODE if(nDBCS%2 == 1) { MessageBeep((UINT)-1); for(i=0; i lpDescript->wMaxCodes) { LoadString(NULL, IDS_DBCSCODELEN, szTmpStr, sizeof(szTmpStr)/sizeof(TCHAR)); #ifdef UNICODE { TCHAR UniTmp[] = {0x884C, 0x0000}; wsprintf(szTemp,TEXT("\'%ws\'%ws %d(%ws:%ld)!"), szDBCS,szTmpStr,(int)lpDescript->wMaxCodes, UniTmp, dwLineNo); } #else wsprintf(szTemp,"\'%s\'%s %d(行:%ld)!", szDBCS,szTmpStr,(int)lpDescript->wMaxCodes, dwLineNo); #endif FatalMessage(hWnd,szTemp); return FALSE; } for(i=0; iszUsedCode,szCode[i]) == NULL) { LoadString(NULL, IDS_DBCSCODE, szTmpStr, sizeof(szTmpStr)/sizeof(TCHAR)); #ifdef UNICODE { TCHAR UniTmp[] = {0x884C, 0x0000}; wsprintf(szTemp,TEXT("\'%ws%ws\' %ws(%ws:%ld) "), szDBCS,szCode,szTmpStr, UniTmp, dwLineNo); } #else wsprintf(szTemp,"\'%s%s\' %s(行:%ld) ", szDBCS,szCode,szTmpStr, dwLineNo); #endif FatalMessage(hWnd,szTemp); return FALSE; } } len = lstrlen(szCreate); if(lpDescript->byMaxElement == 1 || len == 0) return TRUE; for(i=0; iszUsedCode,szCreate[i]) == NULL) { LoadString(NULL, IDS_DBCSCODE, szTmpStr, sizeof(szTmpStr)/sizeof(TCHAR)); #ifdef UNICODE { TCHAR UniTmp[] = {0x884C, 0x0000}; wsprintf(szTemp, TEXT("\'%ws%ws %ws\' %ws(%ws:%ld) "), szDBCS,szCode,szCreate,szTmpStr, UniTmp, dwLineNo); } #else wsprintf(szTemp,"\'%s%s %s\' %s(行:%ld) ", szDBCS,szCode,szCreate,szTmpStr, dwLineNo); #endif FatalMessage(hWnd,szTemp); return FALSE; } } return TRUE; } void DelIllegalCode(TCHAR *szCode) { static TCHAR collection[48]= TEXT("`1234567890-=\\[];',./abcdefghijklmnopqrstuvwxyz"); int i,len = lstrlen(szCode), j; TCHAR szStr[512]; if(len==0) return ; j = 0; for(i=0; i', 0x0000, '<','E','N','T','E','R','>', 0x0000, 0x5149, 0x6807, 0x8DDF, 0x968F, 0x0000 }; #else static TCHAR ValueName[][12]= { "码表文件名", "词语联想", "词语输入", "逐渐提示", "外码提示", "", "", "光标跟随" }; #endif \\UNICODE if(!RegOpenKey(*phKey,KeyName,&hkResult)) return FALSE; if(RegCreateKey(*phKey,KeyName,&hkResult)) return FALSE; RegSetValueEx(hkResult,ValueName[0],0,REG_SZ,(BYTE*)FileName,(lstrlen(FileName)+1) * sizeof(TCHAR) ); for(i=1;i<6;i++) RegSetValueEx(hkResult,ValueName[i],0,REG_DWORD,(LPSTR)&Value,sizeof(DWORD)); RegSetValueEx(hkResult,ValueName[7],0,REG_DWORD,(LPSTR)&Value,sizeof(DWORD)); Value = 0; RegSetValueEx(hkResult,ValueName[5],0,REG_DWORD,(LPSTR)&Value,sizeof(DWORD)); RegSetValueEx(hkResult,ValueName[6],0,REG_DWORD,(LPSTR)&Value,sizeof(DWORD)); RegCloseKey(hkResult); return TRUE; } BOOL SetRegValue(HKEY hKey,LPDWORD Value) { DWORD i; #ifdef UNICODE static TCHAR ValueName[][12]= { 0x8BCD, 0x8BED, 0x8054, 0x60F3, 0x0000, 0x8BCD, 0x8BED, 0x8F93, 0x5165, 0x0000, 0x9010, 0x6E10, 0x63D0, 0x793A, 0x0000, 0x5916, 0x7801, 0x63D0, 0x793A, 0x0000, '<','S','P','A','C','E','>', 0x0000, '<','E','N','T','E','R','>', 0x0000, 0x5149, 0x6807, 0x8DDF, 0x968F, 0x0000 }; #else static TCHAR ValueName[][12]= { "词语联想", "词语输入", "逐渐提示", "外码提示", "", "", "光标跟随" }; #endif \\UNICODE for(i=0;i<7;i++) RegSetValueEx(hKey,ValueName[i],0,REG_DWORD,(LPSTR)&Value[i],sizeof(DWORD)); return TRUE; } BOOL GetRegValue(HWND hDlg,HKEY hKey,LPDWORD Value) { #ifdef UNICODE static TCHAR ValueName[][12]= { 0x8BCD, 0x8BED, 0x8054, 0x60F3, 0x0000, 0x8BCD, 0x8BED, 0x8F93, 0x5165, 0x0000, 0x9010, 0x6E10, 0x63D0, 0x793A, 0x0000, 0x5916, 0x7801, 0x63D0, 0x793A, 0x0000, '<','S','P','A','C','E','>', 0x0000, '<','E','N','T','E','R','>', 0x0000, 0x5149, 0x6807, 0x8DDF, 0x968F, 0x0000 }; #else static TCHAR ValueName[][12]= { "词语联想", "词语输入", "逐渐提示", "外码提示", "", "", "光标跟随" }; #endif \\UNICODE DWORD i,j,retValue,dwcValueName; TCHAR Buf[80]; SetCursor (LoadCursor (NULL, IDC_WAIT)); for (j = 0, retValue = ERROR_SUCCESS; j < 7; j++) { dwcValueName = MAX_VALUE_NAME; i=sizeof(DWORD); retValue = RegQueryValueEx (hKey, ValueName[j], NULL, NULL, //&dwType, (LPSTR)&Value[j], //&bData, &i); //&bcData); if (retValue != (DWORD)ERROR_SUCCESS && retValue != ERROR_INSUFFICIENT_BUFFER) { wsprintf (Buf, TEXT("Line:%d 0 based index = %d, retValue = %d, ValueLen = %d"), __LINE__, j, retValue, dwcValueName); MessageBox (hDlg, Buf, TEXT("Debug"), MB_OK); } }// end for(;;) SetCursor (LoadCursor (NULL, IDC_ARROW)); return TRUE; } LPTSTR _tcschr(LPTSTR string, TCHAR c) { #ifdef UNICODE return (wcschr(string, c)); #else return (strchr(string, c)); #endif } LPTSTR _tcsrchr(LPTSTR string, TCHAR c) { #ifdef UNICODE return (wcsrchr(string, c)); #else return (strrchr(string, c)); #endif } LPTSTR _tcsstr(LPTSTR string1, LPTSTR string2) { #ifdef UNICODE return (wcsstr(string1, string2)); #else return (strstr(string1, string2)); #endif } LPTSTR _tcsupr(LPTSTR string) { #ifdef UNICODE return (_wcsupr(string)); #else return (_strupr(string)); #endif } int _ttoi(LPTSTR string) { #ifdef UNICODE return (_wtoi(string)); #else return (atoi(string)); #endif } int _taccess(LPTSTR szFileName, int mode) { char szDbcsName[256]; #ifdef UNICODE WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, szFileName, -1, szDbcsName, sizeof(szDbcsName), NULL, NULL); #else lstrcpy(szDbcsName, szFileName); #endif return (_access(szDbcsName, mode)); }