本文整理汇总了C++中CString::ReleaseBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::ReleaseBuffer方法的具体用法?C++ CString::ReleaseBuffer怎么用?C++ CString::ReleaseBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::ReleaseBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetLineLength
/**
* @brief Get text of specified lines (ghost lines will not contribute to text).
*
* @param nCrlfStyle determines the EOL type in the returned buffer.
* If nCrlfStyle equals CRLF_STYLE_AUTOMATIC, we read the EOL from the line buffer
*
* @note This function has its base in CrystalTextBuffer
* CrystalTextBuffer::GetTextWithoutEmptys() is for a buffer with no ghost lines.
* CrystalTextBuffer::GetText() returns text including ghost lines.
* These two base functions never read the EOL from the line buffer, they
* use CRLF_STYLE_DOS when nCrlfStyle equals CRLF_STYLE_AUTOMATIC.
*/
void CGhostTextBuffer:: /* virtual override */
GetTextWithoutEmptys(int nStartLine, int nStartChar,
int nEndLine, int nEndChar,
CString &text, CRLFSTYLE nCrlfStyle /*= CRLF_STYLE_AUTOMATIC */,
bool bExcludeInvisibleLines /*= true*/) const
{
const size_t lines = m_aLines.size();
ASSERT(nStartLine >= 0 && nStartLine < static_cast<intptr_t>(lines));
ASSERT(nStartChar >= 0 && nStartChar <= GetLineLength(nStartLine));
ASSERT(nEndLine >= 0 && nEndLine < static_cast<intptr_t>(lines));
ASSERT(nEndChar >= 0 && nEndChar <= GetFullLineLength(nEndLine));
ASSERT(nStartLine < nEndLine || nStartLine == nEndLine && nStartChar <= nEndChar);
// some edit functions (copy...) should do nothing when there is no selection.
// assert to be sure to catch these 'do nothing' cases.
// ASSERT(nStartLine != nEndLine || nStartChar != nEndChar);
// estimate size (upper bound)
int nBufSize = 0;
int i = 0;
for (i = nStartLine; i <= nEndLine; ++i)
nBufSize += (GetFullLineLength(i) + 2); // in case we insert EOLs
LPTSTR pszBuf = text.GetBuffer(nBufSize);
if (nCrlfStyle != CRLF_STYLE_AUTOMATIC)
{
// we must copy this EOL type only
const CString sEol = GetStringEol (nCrlfStyle);
for (i = nStartLine; i <= nEndLine; ++i)
{
// exclude ghost lines
if ((GetLineFlags(i) & LF_GHOST) || (bExcludeInvisibleLines && (GetLineFlags(i) & LF_INVISIBLE)))
continue;
// copy the line, excluding the EOL
int soffset = (i == nStartLine ? nStartChar : 0);
int eoffset = (i == nEndLine ? nEndChar : GetLineLength(i));
int chars = eoffset - soffset;
LPCTSTR szLine = m_aLines[i].GetLine(soffset);
CopyMemory(pszBuf, szLine, chars * sizeof(TCHAR));
pszBuf += chars;
// copy the EOL of the requested type
if (i != ApparentLastRealLine())
{
CopyMemory(pszBuf, sEol, sEol.GetLength() * sizeof(TCHAR));
pszBuf += sEol.GetLength();
}
}
}
else
{
for (i = nStartLine; i <= nEndLine; ++i)
{
// exclude ghost lines
if ((GetLineFlags(i) & LF_GHOST) || (bExcludeInvisibleLines && GetLineFlags(i) & LF_INVISIBLE))
continue;
// copy the line including the EOL
int soffset = (i == nStartLine ? nStartChar : 0);
int eoffset = (i == nEndLine ? nEndChar : GetFullLineLength(i));
int chars = eoffset - soffset;
LPCTSTR szLine = m_aLines[i].GetLine(soffset);
CopyMemory(pszBuf, szLine, chars * sizeof(TCHAR));
pszBuf += chars;
// check that we really have an EOL
if (i != ApparentLastRealLine() && GetLineLength(i) == GetFullLineLength(i))
{
// Oops, real line lacks EOL
// (If this happens, editor probably has bug)
ASSERT(false);
CString sEol = GetStringEol (nCrlfStyle);
CopyMemory(pszBuf, sEol, sEol.GetLength() * sizeof(TCHAR));
pszBuf += sEol.GetLength();
}
}
}
text.ReleaseBuffer(static_cast<int>(pszBuf - text));
text.FreeExtra();
}
示例2: GetShuangSeQiuByStr
//通过字符串获取双色球
sShuangSeQiu CDataManageCenter::GetShuangSeQiuByStr(CString& StrData)
{
sShuangSeQiu ShuangSeQiu;
int StartPos = 0;
int EndPos = 0;
int Index = 0;
int Count=0;
while(EndPos != -1)
{
EndPos=StrData.Find(_T(" "),StartPos);
if(EndPos == -1)
break;
if(Index == 0)
{
ShuangSeQiu.m_QiShu = StrData.Mid(StartPos,EndPos-StartPos);
}
else if(Index == 7)
{
CString Temp = StrData.Mid(StartPos,EndPos-StartPos);
ShuangSeQiu.m_LanQiu = atoi(Temp.GetBuffer());
Temp.ReleaseBuffer();
}
else
{
if(Index > QIU_XUN)
continue;
CString Temp = StrData.Mid(StartPos,EndPos-StartPos);
ShuangSeQiu.m_HongQiu[Index-1]= atoi(Temp.GetBuffer());
Temp.ReleaseBuffer();
Count+=ShuangSeQiu.m_HongQiu[Index-1];
if( ShuangSeQiu.m_HongQiu[Index-1] <= 11)
ShuangSeQiu.m_QuJian[0]++;
else if(ShuangSeQiu.m_HongQiu[Index-1] > 11 && ShuangSeQiu.m_HongQiu[Index-1] <= 22)
ShuangSeQiu.m_QuJian[1]++;
else
ShuangSeQiu.m_QuJian[2]++;
}
Index++;
StartPos = EndPos+1;
}
ShuangSeQiu.m_HongQiuSum = Count;
m_ShuangSeQiuChuHaoList.push_back(ShuangSeQiu);
for(int i = 0; i < QIU_XUN; i++)
{
for(int Index = 0 ; Index < QIU_XUN; Index++)
{
if(ShuangSeQiu.m_HongQiu[i] < ShuangSeQiu.m_HongQiu[Index])
{
int Temp1 = ShuangSeQiu.m_HongQiu[Index];
ShuangSeQiu.m_HongQiu[Index]=ShuangSeQiu.m_HongQiu[i];
ShuangSeQiu.m_HongQiu[i] = Temp1;
}
}
}
return ShuangSeQiu;
}
示例3: InitInstance
BOOL CPrssrApp::InitInstance() {
LOG0(1, "CPrssrApp::InitInstance()");
LoadSSL();
// init win sock
WSADATA wsaData;
WSAStartup(0x0101, &wsaData);
// Change the registry key under which our settings are stored.
SetRegistryKey(_T("DaProfik"));
// register wnd class
WNDCLASS wc = { 0 };
wc.lpfnWndProc = ::DefWindowProc;
wc.hInstance = AfxGetInstanceHandle();
wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
wc.lpszMenuName = NULL;
wc.lpszClassName = PRSSR_CLASS_NAME;
if (!AfxRegisterClass(&wc))
return FALSE;
CFeedView::Register();
CGroupView::Register();
CTextProgressCtrl::Register();
CInfoBar::Register();
// get DPI
HDC hdcScreen = ::GetDC(NULL);
int nSystemDPI = ::GetDeviceCaps(hdcScreen, LOGPIXELSX);
::ReleaseDC(NULL, hdcScreen);
// load the resource library according to the system DPI
CString resLibName;
resLibName.Format(_T("res.%03d.dll"), nSystemDPI);
m_hResDLL = LoadLibrary(resLibName);
if (m_hResDLL == NULL) return Error(IDS_INTERNAL_ERROR, 0x00000002);
if (!InitHTMLControl(AfxGetInstanceHandle()))
return 0;
// Initialize the control
INITCOMMONCONTROLSEX icce;
icce.dwSize = sizeof(icce);
icce.dwICC = ICC_DATE_CLASSES | ICC_LISTVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_UPDOWN_CLASS | ICC_TREEVIEW_CLASSES | ICC_TOOLTIP_CLASSES | ICC_TAB_CLASSES;
InitCommonControlsEx(&icce);
SHInitExtraControls();
// frame
CMainFrame* pFrame = new CMainFrame();
m_pMainWnd = pFrame;
// create and load the frame with its resources
pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW, NULL, NULL);
// process cmd line
CString strCmdLine = m_lpCmdLine;
// minimized ?
if (strCmdLine.Find(_T("/minimized")) != -1) {
pFrame->ShowWindow(SW_MINIMIZE);
}
else {
pFrame->ShowWindow(m_nCmdShow);
pFrame->UpdateWindow();
}
if (strCmdLine.Find(_T("/updateall")) != -1) {
pFrame->PostMessage(UWM_UPDATE_ALL);
}
int npos;
if ((npos = strCmdLine.Find(_T("/opensite"))) != -1) {
CString strSite = strCmdLine.Mid(npos + 10);
int site;
if (swscanf(strSite.GetBuffer(strSite.GetLength()), _T("%d"), &site) == 1) {
// after sites are loaded, site with this value is opened
pFrame->PostMessage(UWM_OPEN_SITE, site, 0);
}
}
if ((npos = strCmdLine.Find(_T("/openitem"))) != -1) {
CString sPar = strCmdLine.Mid(npos + 10);
int site, feedIdx;
if (swscanf(sPar.GetBuffer(sPar.GetLength()), _T("%d %d"), &site, &feedIdx) == 2) {
pFrame->PostMessage(UWM_OPEN_FEEDITEM, site, (LPARAM) feedIdx);
}
sPar.ReleaseBuffer();
}
return TRUE;
}
示例4: GetStatusFromRemoteCache
bool CCacheDlg::GetStatusFromRemoteCache(const CTGitPath& Path, bool bRecursive)
{
if(!EnsurePipeOpen())
{
STARTUPINFO startup = { 0 };
PROCESS_INFORMATION process = { 0 };
startup.cb = sizeof(startup);
CString sCachePath = L"TGitCache.exe";
if (CreateProcess(sCachePath.GetBuffer(sCachePath.GetLength() + 1), L"", nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startup, &process) == 0)
{
// It's not appropriate to do a message box here, because there may be hundreds of calls
sCachePath.ReleaseBuffer();
ATLTRACE("Failed to start cache\n");
return false;
}
sCachePath.ReleaseBuffer();
// Wait for the cache to open
ULONGLONG endTime = GetTickCount64()+1000;
while(!EnsurePipeOpen())
{
if((GetTickCount64() - endTime) > 0)
{
return false;
}
}
}
DWORD nBytesRead;
TGITCacheRequest request;
request.flags = TGITCACHE_FLAGS_NONOTIFICATIONS;
if(bRecursive)
{
request.flags |= TGITCACHE_FLAGS_RECUSIVE_STATUS;
}
wcsncpy_s(request.path, Path.GetWinPath(), MAX_PATH);
SecureZeroMemory(&m_Overlapped, sizeof(OVERLAPPED));
m_Overlapped.hEvent = m_hEvent;
// Do the transaction in overlapped mode.
// That way, if anything happens which might block this call
// we still can get out of it. We NEVER MUST BLOCK THE SHELL!
// A blocked shell is a very bad user impression, because users
// who don't know why it's blocked might find the only solution
// to such a problem is a reboot and therefore they might loose
// valuable data.
// Sure, it would be better to have no situations where the shell
// even can get blocked, but the timeout of 5 seconds is long enough
// so that users still recognize that something might be wrong and
// report back to us so we can investigate further.
TGITCacheResponse ReturnedStatus;
BOOL fSuccess = TransactNamedPipe(m_hPipe,
&request, sizeof(request),
&ReturnedStatus, sizeof(ReturnedStatus),
&nBytesRead, &m_Overlapped);
if (!fSuccess)
{
if (GetLastError()!=ERROR_IO_PENDING)
{
ClosePipe();
return false;
}
// TransactNamedPipe is working in an overlapped operation.
// Wait for it to finish
DWORD dwWait = WaitForSingleObject(m_hEvent, INFINITE);
if (dwWait == WAIT_OBJECT_0)
{
fSuccess = GetOverlappedResult(m_hPipe, &m_Overlapped, &nBytesRead, FALSE);
return TRUE;
}
else
fSuccess = FALSE;
}
ClosePipe();
return false;
}
示例5: GetMsgProc
// The message loop of Mozilla does not handle accelertor keys.
// IOleInplaceActivateObject requires MSG be filtered by its TranslateAccellerator() method.
// So we install a hook to do the dirty hack.
// Mozilla message loop is here:
// http://mxr.mozilla.org/mozilla-central/source/widget/src/windows/nsAppShell.cpp
// bool nsAppShell::ProcessNextNativeEvent(bool mayWait)
// It does PeekMessage, TranslateMessage, and then pass the result directly
// to DispatchMessage.
// Just before PeekMessage returns, our hook procedure is called.
LRESULT CALLBACK WindowMessageHook::GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode >= 0 && wParam == PM_REMOVE && lParam)
{
MSG * pMsg = reinterpret_cast<MSG *>(lParam);
HWND hwnd = pMsg->hwnd;
// 只处理键盘消息
if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST || hwnd == NULL)
{
goto Exit;
}
// 只处理IE窗口消息,通过检查窗口类名过滤非IE窗口
CString strClassName;
GetClassName(hwnd, strClassName.GetBuffer(MAX_PATH), MAX_PATH);
strClassName.ReleaseBuffer();
if (WM_KEYDOWN == pMsg->message && VK_TAB == pMsg->wParam && strClassName == _T("Internet Explorer_TridentCmboBx"))
{
hwnd = ::GetParent(hwnd);
GetClassName(hwnd, strClassName.GetBuffer(MAX_PATH), MAX_PATH);
strClassName.ReleaseBuffer();
}
if (strClassName != _T("Internet Explorer_Server"))
{
goto Exit;
}
// 获取CIEHostWindow对象
CIEHostWindow* pIEHostWindow = CIEHostWindow::FromInternetExplorerServer(hwnd);
if (pIEHostWindow == NULL)
{
goto Exit;
}
if (pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_SYSKEYUP)
{
BOOL bAltPressed = HIBYTE(GetKeyState(VK_MENU)) != 0;
BOOL bCtrlPressed = HIBYTE(GetKeyState(VK_CONTROL)) != 0;
BOOL bShiftPressed = HIBYTE(GetKeyState(VK_SHIFT)) != 0;
// 当Alt键释放时,也向Firefox窗口转发按钮消息。否则无法通过Alt键选中主菜单。
if (pMsg->message == WM_SYSKEYUP && pMsg->wParam == VK_MENU)
{
bAltPressed = TRUE;
}
TRACE(_T("WindowMessageHook::GetMsgProc MSG: %x wParam: %x, lPara: %x\n"), pMsg->message, pMsg->wParam, pMsg->lParam);
if (bCtrlPressed || bAltPressed || (pMsg->wParam >= VK_F1 && pMsg->wParam <= VK_F24))
{
int nKeyCode = static_cast<int>(pMsg->wParam);
if (FilterFirefoxKey(nKeyCode, bAltPressed, bCtrlPressed, bShiftPressed))
{
HWND hwndMessageTarget = GetTopMozillaWindowClassWindow(pIEHostWindow->GetSafeHwnd());
if (hwndMessageTarget)
{
::SetFocus(hwndMessageTarget);
::PostMessage(hwndMessageTarget, pMsg->message, pMsg->wParam, pMsg->lParam);
pMsg->message = WM_NULL;
goto Exit;
}
}
}
}
if (pIEHostWindow->m_ie.TranslateAccelerator(pMsg) == S_OK)
{
pMsg->message = WM_NULL;
}
}
Exit:
return CallNextHookEx(s_hhookGetMessage, nCode, wParam, lParam);
}
示例6: InsertString
//插入字串
bool CSkinRichEdit::InsertString(LPCTSTR pszString, CHARFORMAT2 & CharFormat)
{
//变量定义
bool bResumeSelect;
CHARRANGE CharRange;
//保存状态
GetSel(CharRange.cpMin,CharRange.cpMax);
bResumeSelect=(CharRange.cpMax!=CharRange.cpMin);
//搜索变量
LPCTSTR pszHttp=TEXT("http://");
const INT nHttpLength=lstrlen(pszHttp);
const INT nStringLength=lstrlen(pszString);
//索引定义
INT nStringStart=0;
INT nStringPause=0;
//字符解释
for (INT i=0;i<nStringLength;i++)
{
//变量定义
INT nUrlPause=i;
//地址判断
if (((i+nHttpLength)<nStringLength)&&(memcmp(&pszString[i],pszHttp,nHttpLength*sizeof(TCHAR))==0))
{
//设置索引
nUrlPause=i+nHttpLength;
//地址搜索
while (nUrlPause<nStringLength)
{
//字符判断
if (EfficacyUrlChar(pszString[nUrlPause])==true)
{
nUrlPause++;
continue;
}
break;
}
}
//终止字符
if (nUrlPause<=(i+nHttpLength)) nStringPause=(i+1);
//插入字符
if ((i==(nStringLength-1))||(nUrlPause>(i+nHttpLength)))
{
//普通字符
if (nStringPause>nStringStart)
{
//获取缓冲
CString strNormalString;
LPTSTR pszNormalString=strNormalString.GetBuffer(nStringPause-nStringStart+1);
//拷贝字符
pszNormalString[nStringPause-nStringStart]=0;
CopyMemory(pszNormalString,&pszString[nStringStart],(nStringPause-nStringStart)*sizeof(TCHAR));
//释放缓冲
strNormalString.ReleaseBuffer();
//插入消息
SetSel(-1L,-1L);
SetWordCharFormat(CharFormat);
ReplaceSel((LPCTSTR)strNormalString);
}
//连接地址
if (nUrlPause>(i+nHttpLength))
{
//获取缓冲
CString strUrlString;
LPTSTR pszUrlString=strUrlString.GetBuffer((nUrlPause-i)+1);
//拷贝字符
pszUrlString[nUrlPause-i]=0;
CopyMemory(pszUrlString,&pszString[i],(nUrlPause-i)*sizeof(TCHAR));
//释放缓冲
strUrlString.ReleaseBuffer();
//构造格式
CHARFORMAT2 CharFormatHyper;
CharFormatHyper=CharFormat;
//效验地址
if (EfficacyUrlString(strUrlString)==true)
{
CharFormatHyper.dwMask|=CFM_LINK;
CharFormatHyper.dwEffects|=CFE_LINK;
}
//插入消息
SetSel(-1L,-1L);
SetWordCharFormat(CharFormatHyper);
//.........这里部分代码省略.........
示例7: Trace
///////////////////////////////////////////////////////////////////////////////
//
// 函数功能描述:标准日志打印
// 输入:日志级别、类型、源文件名、代码行,格式字串
// 输出:向窗口或文件写日志
// 返回值:
// 其它说明:
//
///////////////////////////////////////////////////////////////////////////////
void CLogTrace::Trace(BYTE cLevel, BYTE cType, const TCHAR * pszSourceFile,
DWORD dwLine, LPCTSTR lpszFormat, ...)
{
if (! IsLogFileEnable()) return;
//指定类型级别以下的日志不打印;
if ( m_nOutLogLevel < cType )
{
return;
}
//合法性检测
if (!pszSourceFile || !lpszFormat)
{
OutputDebugString(_T("Error: pszSourceFile or lpszFormat is NULL\r\n"));
return;
}
//读取参数
va_list args;
va_start(args, lpszFormat);
CLocalLock localLock(&m_lock); //锁
//打入字串
m_szBuffer[0][0] = 0;
int nBuf = -1;
if(cType == LOGT_COMPRESS) //对打印的日志进行压缩
{
TCHAR *tmp = new TCHAR[200000];
memset(tmp,0,200000 * sizeof(TCHAR));
int nBuf = _vsntprintf(tmp,200000-1,lpszFormat,args);
CString strSource,strZipData;
strSource.Format(_T("%s"),tmp);
if (strSource.GetLength() < 100)
{
strZipData = strSource;
}
else
{
ZipEecodeStdString(strSource,strZipData);
}
_tcsncpy(m_szBuffer[0],strZipData.GetBuffer(strZipData.GetLength()),MAX_LEN_OF_LOG_LINE-128);
strZipData.ReleaseBuffer();
delete []tmp;
}
else
{
nBuf = _vsntprintf(m_szBuffer[0], MAX_LEN_OF_LOG_LINE - 128, lpszFormat, args);
}
va_end(args);
if (nBuf < 0) //出错
{
//有可能是字符串太长
m_szBuffer[0][MAX_LEN_OF_LOG_LINE - 128] = 0;
}
//取系统日期、时间
TCHAR szData[12], szTime[12];
_tstrdate(szData);
_tstrtime(szTime);
//类型字串及颜色
CString strType;
DWORD dwColor = 0;
//获取日志的类型文本及颜色
GetLogType(strType,dwColor,cType);
//源文件名缩短处理
TCHAR * pszSourceShort = NULL;
TCHAR szSourceShort[MAX_PATH];
WORD wSourceNameLen = lstrlen(pszSourceFile);
if (wSourceNameLen > LEN_SHORT_SOURCEFILE_NAME) //太长
{
wsprintf(szSourceShort, _T("...%s"),
pszSourceFile + (wSourceNameLen - LEN_SHORT_SOURCEFILE_NAME));
pszSourceShort = szSourceShort;
}
else
{
pszSourceShort = (TCHAR *)pszSourceFile;
}
//形成结果字串
nBuf = _sntprintf(m_szBuffer[1], MAX_LEN_OF_LOG_LINE,
_T("%s %s [%d]%s: %s at %d in %s\r\n"), szData, szTime, GetCurrentThreadId(), strType.GetBuffer(),
m_szBuffer[0], dwLine, pszSourceShort);
if (nBuf < 0) //出错
{
//.........这里部分代码省略.........
示例8: ScanChromePass
BOOL CChromClean::ScanChromePass()
{
if (!_CheckChromeExist())
{
g_vsNoinstallapp.Add(CHROME_PASSWORD);
return TRUE;
}
CSimpleArray<CString> vec_file;
CString strPath;
g_fnScanFile(g_pMain,BEGINPROC(CHROME_PASSWORD),0,0,0);
std::wstring str;
std::vector<std::wstring>::iterator it;
for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ )
{
str = *it;
transform(str.begin(), str.end(), str.begin(), towlower);
if (str == L"chrome.exe")
{
str = L"正在运行,跳过";
goto _exit_;
}
}
str = L"";
if (m_bScan ==TRUE)
{
TCHAR szBuffer[MAX_PATH] = {0};
::SHGetSpecialFolderPath( NULL, szBuffer, CSIDL_LOCAL_APPDATA, FALSE);
strPath = szBuffer;
strPath += _T("\\Google\\Chrome\\User Data\\Default");
sqlite3* pDB = NULL;
sqlite3_stmt* sspStart = NULL;
CString strDbPath = L"";
strPath += L"\\";
FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Web Data"));
strPath.ReleaseBuffer();
if (strDbPath.GetLength()>=0)
{
KW2UTF8 szDataPath(strDbPath.GetBuffer());
int nResult = sqlite3_open(szDataPath, &pDB);
if (nResult != SQLITE_OK)
{
goto _exit_1;
}
nResult = sqlite3_prepare(pDB, "select * from logins", -1, &sspStart, 0);
if (nResult != SQLITE_OK)
{
goto _exit_1;
}
nResult = sqlite3_step(sspStart);
if(nResult == SQLITE_ROW)
{
CString strOutPut = strDbPath;
strOutPut += L"|logins";
g_fnScanFile(g_pMain, CHROME_PASSWORD, strOutPut, 0, 0);
}
_exit_1:
if (sspStart)
{
sqlite3_finalize(sspStart);
sspStart = NULL;
}
if (pDB)
{
sqlite3_close(pDB);
pDB = NULL;
}
}
strDbPath = L"";
FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Login Data"));
strPath.ReleaseBuffer();
if (strDbPath.GetLength()>=0)
{
KW2UTF8 szDataPath(strDbPath.GetBuffer());
strDbPath.ReleaseBuffer();
int nResult = sqlite3_open(szDataPath, &pDB);
if (nResult != SQLITE_OK)
{
goto _exit_2;
}
nResult = sqlite3_prepare(pDB, "select * from logins", -1, &sspStart, 0);
if (nResult != SQLITE_OK)
{
goto _exit_2;
}
nResult = sqlite3_step(sspStart);
//.........这里部分代码省略.........
示例9: CleanChromePass
BOOL CChromClean::CleanChromePass(CString& strInPath)
{
sqlite3* pDB = NULL;
BOOL bRet = TRUE;
if (strInPath.Find(L'|')==-1)
{
bRet = FALSE;
return bRet;
}
TCHAR szBuffer[MAX_PATH] = {0};
::SHGetSpecialFolderPath( NULL, szBuffer, CSIDL_LOCAL_APPDATA, FALSE);
CString strPath = szBuffer;
strPath += _T("\\Google\\Chrome\\User Data\\Default");
CString strDbPath = L"";
strPath += L"\\";
FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Web Data"));
strPath.ReleaseBuffer();
if (strDbPath.GetLength()>=0)
{
KW2UTF8 szDataPath(strDbPath.GetBuffer());
strDbPath.ReleaseBuffer();
char* szError = NULL;
char szSql[MAX_PATH] = {0};
int nResult = sqlite3_open(szDataPath, &pDB);
if (nResult != SQLITE_OK)
{
goto _exit_1;
}
sprintf_s(szSql, MAX_PATH - 1, "delete from logins");
nResult = sqlite3_exec(pDB, szSql, 0, 0, &szError);
if(nResult != SQLITE_OK)
{
}
_exit_1:
if (pDB)
{
sqlite3_close(pDB);
pDB = NULL;
}
}
strDbPath = L"";
FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("Login Data"));
strPath.ReleaseBuffer();
if (strDbPath.GetLength()>=0)
{
KW2UTF8 szDataPath(strDbPath.GetBuffer());
strDbPath.ReleaseBuffer();
char* szError = NULL;
char szSql[MAX_PATH] = {0};
int nResult = sqlite3_open(szDataPath, &pDB);
if (nResult != SQLITE_OK)
{
bRet = FALSE;
goto _exit_2;
}
sprintf_s(szSql, MAX_PATH - 1, "delete from logins");
nResult = sqlite3_exec(pDB, szSql, 0, 0, &szError);
if(nResult != SQLITE_OK)
{
}
_exit_2:
if (pDB)
{
sqlite3_close(pDB);
pDB = NULL;
}
}
bRet = TRUE;
return TRUE;
//.........这里部分代码省略.........
示例10: WirteBatteryParameters
void CDlgBatteryParam::WirteBatteryParameters()
{
bool bIsRun=true;
::SendMessage((HWND)g_msgHwnd,WM_TEST_RUNNING,0,(LPARAM)&bIsRun);
if (!bIsRun)
{
CString strInfo;
if (!PathFileExists(strResourceDtsPath))
{
GetPrivateProfileStringW(_T("Prompt"),_T("ERROR_NOFOUND_RESOURCE"),_T("ERROR_NOFOUND_RESOURCE"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
strInfo.ReleaseBuffer(MAX_LENGTH);
return;
}
if(BatteryParamReadFile(strResourceDtsPath)<0)
{
GetPrivateProfileStringW(_T("Prompt"),_T("ERROR_READ_DTS_FILE"),_T("ERROR_READ_DTS_FILE"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
strInfo.ReleaseBuffer(MAX_LENGTH);
return;
}
STRUCT_BATTERY_PARAM param;
if (!GetParamFromInterface(¶m))
{
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_INVALID_PARAM"),_T("IDS_ERROR_INVALID_PARAM"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
return;
}
int iRet;
iRet = WriteBatteryParam(strResourceDtsPath,¶m);
if (iRet==0)
{
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_INFO_WRITE_OK"),_T("IDS_INFO_WRITE_OK"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
MessageBox(strInfo,m_strMsgBoxTitle);
return;
}
else
{
if (iRet==-2)
{
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_INVALID_RESOURCE"),_T("IDS_ERROR_INVALID_RESOURCE"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
}
else{
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_NO_PARAM"),_T("IDS_ERROR_NO_PARAM"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
}
MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
return;
}
}
}
示例11: ScanChrome
BOOL CChromClean::ScanChrome()
{
//文件部分
if (!_CheckChromeExist())
{
g_vsNoinstallapp.Add(BROWSERSCLEAN_CHROME);
return TRUE;
}
CSimpleArray<CString> vec_file;
CString strPath;
std::wstring str;
g_fnScanFile(g_pMain,BEGINPROC(BROWSERSCLEAN_CHROME),0,0,0);
std::vector<std::wstring>::iterator it;
for (it = g_listProcessName.begin(); it != g_listProcessName.end(); it++ )
{
str = *it;
transform(str.begin(), str.end(), str.begin(), towlower);
if (str == L"chrome.exe")
{
str = L"正在运行,跳过";
goto _exit_;
}
}
str = L"";
if (m_bScan ==TRUE)
{
TCHAR szBuffer[MAX_PATH] = {0};
::SHGetSpecialFolderPath( NULL, szBuffer, CSIDL_LOCAL_APPDATA, FALSE);
strPath = szBuffer;
strPath += _T("\\Google\\Chrome\\User Data\\Default\\Cache");
m_appHistory.CommfunFile(BROWSERSCLEAN_CHROME,strPath,vec_file);
strPath = szBuffer;
strPath += _T("\\Google\\Chrome\\User Data\\Default\\Media Cache");
m_appHistory.CommfunFile(BROWSERSCLEAN_CHROME,strPath,vec_file);
//vec_file.Add(_T("Cookies"));
//vec_file.Add(_T("Extension Cookies"));
vec_file.Add(_T("Archived History"));
//vec_file.Add(_T("History"));
//vec_file.Add(_T("History-journal"));
//vec_file.Add(_T("Thumbnails"));
//vec_file.Add(_T("Thumbnails-journal"));
vec_file.Add(_T("Current Tabs"));
vec_file.Add(_T("Current Session"));
vec_file.Add(_T("Last Tabs"));
vec_file.Add(_T("Last Session"));
vec_file.Add(_T("Safe Browsing Bloom"));
vec_file.Add(_T("History Index*"));
vec_file.Add(_T("Visited Links"));
//vec_file.Add(_T("Extension Cookies"));
strPath = szBuffer;
strPath += _T("\\Google\\Chrome\\User Data\\Default");
m_appHistory.CommfunFile(BROWSERSCLEAN_CHROME,strPath,vec_file);
vec_file.RemoveAll();
sqlite3* pDB = NULL;
sqlite3_stmt* sspStart = NULL;
CString strDbPath = L"";
strPath += L"\\";
FindFileInDirectory(strPath.GetBuffer(),strDbPath,_T("History"));
strPath.ReleaseBuffer();
if (strDbPath.GetLength()>=0)
{
KW2UTF8 szDataPath(strDbPath.GetBuffer());
strDbPath.ReleaseBuffer();
int nResult = sqlite3_open(szDataPath, &pDB);
if (nResult != SQLITE_OK)
{
goto _exit_1;
}
nResult = sqlite3_prepare(pDB, "select * from segments", -1, &sspStart, 0);
if (nResult != SQLITE_OK)
{
goto _exit_1;
}
nResult = sqlite3_step(sspStart);
if(nResult == SQLITE_ROW)
{
CString strOutPut = strDbPath;
strOutPut += L"|segments";
g_fnScanFile(g_pMain, BROWSERSCLEAN_CHROME, strOutPut, 0, 0);
}
_exit_1:
if (sspStart)
{
sqlite3_finalize(sspStart);
sspStart = NULL;
}
if (pDB)
{
//.........这里部分代码省略.........
示例12: ReadBatteryParameters
void CDlgBatteryParam::ReadBatteryParameters()
{
bool bIsRun=true;
::SendMessage((HWND)g_msgHwnd,WM_TEST_RUNNING,0,(LPARAM)&bIsRun);
if (!bIsRun)
{
char szDir[MAX_PATH];
memset(szDir,0,MAX_PATH);
::SendMessage((HWND)g_msgHwnd,WM_GET_DIR,(WPARAM)EmMsg_Root_key,(LPARAM)szDir);
if (strlen(szDir)>0)
{
BOOL bRet = FALSE;
LPWSTR lpDir = NULL;
int nSize = 0;
bRet = AnsiToUnicode(lpDir,nSize,szDir);
if (bRet)
{
CString strInfo;
CString strKernelPath=lpDir;
delete []lpDir;
lpDir = NULL;
strKernelPath += _T("\\Image\\kernel.img");
if (!PathFileExists(strKernelPath))
{
GetPrivateProfileStringW(_T("Prompt"),_T("ERROR_NOFOUND_KERNEL"),_T("ERROR_NOFOUND_KERNEL"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
strInfo.ReleaseBuffer(MAX_LENGTH);
return;
}
STRUCT_BATTERY_PARAM param;
int iRet;
iRet = ReadBatteryParam(strKernelPath,¶m);
if (iRet==0)
{
UpdateParamToInterface(¶m);
return;
}
else
{
ClearParamInterface();
if (iRet==-4)
{
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_INVALID_KERNEL"),_T("IDS_ERROR_INVALID_KERNEL"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
}
else if (iRet==-5)
{
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_NO_PARAM"),_T("IDS_ERROR_NO_PARAM"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
}
else
GetPrivateProfileStringW(_T("BatteryParam"),_T("IDS_ERROR_READ_FAIL"),_T("IDS_ERROR_READ_FAIL"),
strInfo.GetBuffer(MAX_LENGTH),MAX_LENGTH, g_strLanguageConfigFilePath);
MessageBox(strInfo,m_strMsgBoxTitle,MB_OK|MB_ICONERROR);
strInfo.ReleaseBuffer(MAX_LENGTH);
return;
}
}
}
}
}
示例13: OnFileSave
void CMainFrame::OnFileSave()
{
CFileDialog dlg(
FALSE,
_T("UI state"),
_T(".\\Default.UI state"),
OFN_ENABLESIZING|OFN_EXPLORER
|OFN_LONGNAMES|OFN_PATHMUSTEXIST
|OFN_NOCHANGEDIR|OFN_NODEREFERENCELINKS
,
_T("UI state files (*.UI state)|*.UI state|All files (*.*)|*.*||"),
this
);
dlg.m_ofn.lpstrTitle = _T("Save UI state to file");
if( dlg.DoModal() != IDOK )
return;
ASSERT( dlg.m_ofn.lpstrFile != NULL );
try
{
CFile _file(
dlg.m_ofn.lpstrFile,
CFile::modeCreate|CFile::modeWrite|CFile::shareExclusive
);
CArchive ar( &_file, CArchive::store);
CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );
ASSERT( pApp->m_pszRegistryKey != NULL );
ASSERT( pApp->m_pszRegistryKey[0] != _T('\0') );
ASSERT( pApp->m_pszProfileName != NULL );
ASSERT( pApp->m_pszProfileName[0] != _T('\0') );
VERIFY(
CExtControlBar::ProfileBarStateSerialize(
ar,
this
)
);
VERIFY(
g_CmdManager->SerializeState(
pApp->m_pszProfileName,
ar
)
);
} // try
catch( CException * pXept )
{
CString sErrorDescription;
VERIFY(
pXept->GetErrorMessage(
sErrorDescription.GetBuffer(8192), 8192
)
);
sErrorDescription.ReleaseBuffer();
ASSERT( !sErrorDescription.IsEmpty() );
pXept->Delete();
MessageBox(
LPCTSTR(sErrorDescription),
_T("State save failed"),
MB_ICONERROR
);
} // catch( CException * pXept )
catch( ... )
{
MessageBox(
_T("Unknown exception caught"),
_T("State save failed"),
MB_ICONERROR
);
} // catch( ... )
}
示例14: GetMacData
//.........这里部分代码省略.........
//iCode = ZT_EPP_SetDesPara(2, 0xFF);
//(3)启动密码键盘加密
iCode = ZT_EPP_PinStartAdd(6, 1, 0, 0, 30);
AllowInput = true;
//(4)循环获取使用者按键键值
ZtPwdEncryptInput();
AllowInput = false;
//(5)激活PIN运算时使用的密钥号 -- 取PIN值,前加密
if (strcmp(szKeyMode.GetBuffer(),"IC") == 0)
iCode = ZT_EPP_ActivWorkPin(0, 0);
else if (strcmp(szKeyMode.GetBuffer(),"SAM") == 0)
iCode = ZT_EPP_ActivWorkPin(0, 0x40);
////键盘输入PIN采用内置3DES-2key密码算法,工作密钥加密
//iCode = ZT_EPP_SetDesPara(1, 0x30);
////键盘输入PIN短时,用<F>值填充PIN右边直至8字节
//iCode = ZT_EPP_SetDesPara(2, 0xFF);
iCode = ZT_EPP_SetDesPara(4, 0x10);
//(6)设置卡号
char cAccount[13] ={'\0'};
int offset = strlen(sAccount) - 13;
memcpy(cAccount,sAccount + offset,12);
iCode = ZT_EPP_PinLoadCardNo(cAccount);
if (iCode != 0)
{
//LogManager.WriteLog(LogFile.Error , " 任务出错: 无法设置卡号!" + "\r\n");
ZT_EPP_CloseCom();
return -1;
}
//(7)最后接收取PIN密文
unsigned char cPin[20]={'\0'};
iCode = ZT_EPP_PinReadPin(2, cPin);
if (iCode != 0)
{
//LogManager.WriteLog(LogFile.Error , " 任务出错: 取PIN密文出错," + iCode + "\r\n");
ZT_EPP_CloseCom();
return -1;
}
package->SetFieldData(52,8,cPin);
}
//(7) 关闭金属键盘
ZT_EPP_OpenKeyVoic(0);
if (strcmp(szKeyMode.GetBuffer(),"SAM") == 0)
{
iCode = ZT_EPP_SetDesPara(0, 0x30);
if (iCode != 0)
{
//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置算法参数出错," + iCode + "\r\n");
ZT_EPP_CloseCom();
return -1;
}
iCode = ZT_EPP_SetDesPara(1, 0x30);
if (iCode != 0)
{
//LogManager.WriteLog(LogFile.Error , " 任务出错: 设置算法参数出错," + iCode + "\r\n");
ZT_EPP_CloseCom();
return -1;
}
}
//激活工作密钥 - MAC
iCode = ZT_EPP_ActivWorkPin(0, 1);
//取需要进行MAC计算的数据
BYTE cData[1024];
memset(cData,0,1024);
BYTE cType[] ={0x02,0x00};
int nLen = package->GetData(cData,1024,cType,2,true);
int nGroup = 0;
if( nLen % 8 == 0)
nGroup = nLen / 8;
else
nGroup = nLen / 8 + 1;
CString sMacData = Convert2Hex((char *)cData,nGroup * 8);
//MAC加密运算
char cMac[17]={'\0'};
iCode = ZT_EPP_PinCalMAC(1, 4, /*cMacData*/sMacData.GetBuffer(), cMac);
if (iCode != 0)
{
//LogManager.WriteLog(LogFile.Error , " 任务出错: MAC加密运算出错," + iCode + "\r\n");
ZT_EPP_CloseCom();
return -1;
}
sMacData.ReleaseBuffer();
//关闭串口
iCode = ZT_EPP_CloseCom();
package->SetFieldData(64,8,(BYTE*)cMac);
return 0;
}
示例15: PackageFileTransfer
/*
* This function is called when the remote connection, whant to send a file.
*
*/
void MyIOCP::PackageFileTransfer(CIOCPBuffer *pOverlapBuff,int nSize,ClientContext *pContext)
{
#ifdef TRANSFERFILEFUNCTIONALITY
CString sFileName="";
UINT iMaxFileSize=0;
BYTE dummy=0;
if(pOverlapBuff->GetPackageInfo(dummy,iMaxFileSize,sFileName))
{
// Get The Current Path name and application name.
CString sFilePath="";
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
CString strTemp;
GetModuleFileName(NULL,strTemp.GetBuffer(MAX_PATH),MAX_PATH);
strTemp.ReleaseBuffer();
_splitpath( strTemp, drive, dir, fname, ext );
sFilePath=drive; //Drive
sFilePath+=dir; //dir
sFilePath+=sFileName; //name..
TRACE("Incoming File >%s.\r\n",sFilePath);
// Perpare for Receive
if(PrepareReceiveFile(pContext->m_Socket,sFilePath,iMaxFileSize))
{
// Send start file transfer..
CIOCPBuffer *pOverlapBuff=AllocateBuffer(IOWrite);
if(pOverlapBuff)
{
if(pOverlapBuff->CreatePackage(Job_StartFileTransfer))
ASend(pContext,pOverlapBuff);
}
}else
{
// Abort Transfer.
CIOCPBuffer *pOverlapBuff=AllocateBuffer(IOWrite);
if(pOverlapBuff)
{
if(pOverlapBuff->CreatePackage(Job_AbortFileTransfer))
ASend(pContext,pOverlapBuff);
}
}
// to be sure that pcontext Suddenly does not dissapear..
m_ContextMapLock.Lock();
pContext->m_ContextLock.Lock();
pContext->m_sReceived=sFilePath;
// Update that we have data
pContext->m_iNumberOfReceivedMsg++;
pContext->m_ContextLock.Unlock();
m_ContextMapLock.Unlock();
// Update Statistics.
m_StatusLock.Lock();
m_iNumberOfMsg++;
m_StatusLock.Unlock();
}
#endif
}