//************************************ // Method: GetUserProfileDir : Read in user profile directory // FullName: CAutoStartupInfo::GetUserProfileDir // Access: private // Returns: bool // Qualifier: const // Parameter: CString & csUserProfileDir_o // Parameter: CString & csAllUserProfileDir_o //************************************ bool CAutoStartupInfo::GetUserProfileDir( CString& csUserProfileDir_o, CString& csAllUserProfileDir_o ) const { HANDLE hProcToken = 0; if( !OpenProcessToken( GetCurrentProcess(), TOKEN_READ, &hProcToken )) { TRACE_ERR( "Failed to open process token for accessing user profile directory" ); return false; }// End if // Auto closes handle when out of scope Utils::AutoHandleMgr ahmHndlMgr( hProcToken ); // Read in user profile directory DWORD dwProfileDirBuffLen = MAX_PATH; const BOOL bCurrUserResult = ::GetUserProfileDirectory( hProcToken, csUserProfileDir_o.GetBufferSetLength( dwProfileDirBuffLen ), &dwProfileDirBuffLen ); csUserProfileDir_o.ReleaseBuffer(); // Reset buffer length dwProfileDirBuffLen = MAX_PATH; // Read in all users profile directory const BOOL bAllUserResult = ::GetAllUsersProfileDirectory( csAllUserProfileDir_o.GetBufferSetLength( dwProfileDirBuffLen ), &dwProfileDirBuffLen ); csAllUserProfileDir_o.ReleaseBuffer(); // Return status return ( bCurrUserResult != FALSE || bAllUserResult != FALSE ); }// End GetUserProfileDir
void CArrayMatrix::ProcStringBlank(CString & sHead) { int len=lstrlen(sHead); if(len==0) return; CString m_temp=sHead; sHead.GetBufferSetLength(len+1); int j=0; for(int i=0;i<len;i++) { if(m_temp[i]==TCHAR(' ')) { if((i+1)!=len&&m_temp[i+1]==TCHAR(' ')) continue; else { sHead.SetAt(j,sHead[i]); j++; } } else {sHead.SetAt(j,m_temp[i]);j++;} } sHead.SetAt(j,TCHAR('\0')); j=lstrlen(sHead); sHead.GetBufferSetLength(j); sHead.Replace(" \n","\n"); sHead.Replace("\n ","\n"); }
// ---------------------------------------------------------------------------- // bool SpotifyEngine::_readCredentials( CString& username, CString& credentials ) { CString filename; filename.Format( "%s\\DMXStudio\\SpotifyCredentials", getUserDocumentDirectory() ); username.Empty(); credentials.Empty(); if ( GetFileAttributes( filename ) == INVALID_FILE_ATTRIBUTES ) return false; FILE* hFile = _fsopen( filename, "rt", _SH_DENYWR ); if ( hFile == NULL ) return false; LPSTR lpUsername = username.GetBufferSetLength( 256 ); LPSTR lpCredentials = credentials.GetBufferSetLength( 2048 ); size_t read = fscanf_s( hFile, "%s %s", lpUsername, 256, lpCredentials, 256 ); username.ReleaseBuffer(); credentials.ReleaseBuffer(); fclose( hFile ); return read == 2; }
BOOL CConfigLoader::LoadConfig( CString szFileName ) { if( szFileName.GetLength() > 0 ) m_szFileName = szFileName; int nLen = 0; int nBufferLen = 0; CString szBuffer; CString szWork; CString szSection; CString szKey; CString szValue; CMapStringToString *lpKeyMap = NULL; TCHAR* lpBuffer = szBuffer.GetBufferSetLength(4096); szValue.GetBufferSetLength(2048); m_SectionMap.RemoveAllWithDelete(); nBufferLen = GetPrivateProfileString( NULL, NULL, NULL, lpBuffer, szBuffer.GetLength(), m_szFileName ); // セクションリスト作成 for( nLen=0; nLen<nBufferLen; nLen++ ) { if(lpBuffer[nLen]==0x00) break; szWork = &lpBuffer[nLen]; m_SectionMap.SetAtWithNew( szWork ); nLen += szWork.GetLength(); } // セクションごとにキーを追加 POSITION pos = m_SectionMap.GetStartPosition(); while( pos ) { lpKeyMap = NULL; m_SectionMap.GetNextAssoc( pos, szSection, lpKeyMap ); nBufferLen = GetPrivateProfileString( szSection, NULL, NULL, lpBuffer, szBuffer.GetLength(), m_szFileName ); for( nLen=0; nLen<nBufferLen; nLen++ ) { if(lpBuffer[nLen]==0x00) break; szKey = &lpBuffer[nLen]; GetPrivateProfileString( szSection, szKey, NULL, szValue.GetBuffer(), szBuffer.GetLength(), m_szFileName ); lpKeyMap->SetAt( szKey, szValue ); nLen += szKey.GetLength(); } } return TRUE; }
void CConfig::AutoRun_RegKey(CString AutoRun) { if (AutoRun==_T("1")) { TCHAR path[MAX_PATH]; CString keyStr; CString fileName; HKEY hRegKey; GetModuleFileName(NULL,path,sizeof(path)); CString strPath = path; keyStr =_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if(RegOpenKey(HKEY_LOCAL_MACHINE,keyStr,&hRegKey) != ERROR_SUCCESS) return ; else { _wsplitpath(strPath.GetBuffer(0),NULL,NULL,fileName.GetBufferSetLength(MAX_PATH+1),NULL); if(!::RegSetValueEx(hRegKey, fileName, 0, REG_SZ, (CONST BYTE *)strPath.GetBuffer(0), strPath.GetLength()*2)!= ERROR_SUCCESS) return; strPath.ReleaseBuffer(); } } else { TCHAR path[MAX_PATH]; CString str; HKEY hRegKey; BOOL bResult; GetModuleFileName(NULL,path,sizeof(path)); CString strPath = path; str=_T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); if(RegOpenKey(HKEY_LOCAL_MACHINE, str, &hRegKey) != ERROR_SUCCESS) bResult=FALSE; else { _wsplitpath(strPath.GetBuffer(0),NULL,NULL,str.GetBufferSetLength(MAX_PATH+1),NULL); strPath.ReleaseBuffer(); str.ReleaseBuffer(); if(::RegDeleteValue(hRegKey, str) != ERROR_SUCCESS) bResult=FALSE; else bResult=TRUE; strPath.ReleaseBuffer(); } } }
void CGitPropertyPage::DisplayCommit(const git_commit* commit, UINT hashLabel, UINT subjectLabel, UINT authorLabel, UINT dateLabel) { if (commit == NULL) { SetDlgItemText(m_hwnd, hashLabel, _T("")); SetDlgItemText(m_hwnd, subjectLabel, _T("")); SetDlgItemText(m_hwnd, authorLabel, _T("")); SetDlgItemText(m_hwnd, dateLabel, _T("")); return; } int encode = CP_UTF8; const char * encodingString = git_commit_message_encoding(commit); if (encodingString != NULL) encode = CUnicodeUtils::GetCPCode(CUnicodeUtils::GetUnicode(encodingString)); const git_signature * author = git_commit_author(commit); CString authorName = CUnicodeUtils::GetUnicode(author->name, encode); CString message = CUnicodeUtils::GetUnicode(git_commit_message(commit), encode); int start = 0; message = message.Tokenize(L"\n", start); SetDlgItemText(m_hwnd, hashLabel, CGitHash((char*)(git_commit_id(commit)->id)).ToString()); SetDlgItemText(m_hwnd, subjectLabel, message); SetDlgItemText(m_hwnd, authorLabel, authorName); CString authorDate; Time64ToTimeString(author->when.time, authorDate.GetBufferSetLength(200), 200); SetDlgItemText(m_hwnd, dateLabel, authorDate); }
void CPatchListCtrl::OnDropFiles(HDROP hDropInfo) { UINT nNumFiles = DragQueryFile(hDropInfo, 0xFFFFFFFF, nullptr, 0); for (UINT i = 0; i < nNumFiles; ++i) { CString file; DragQueryFile(hDropInfo, i, file.GetBufferSetLength(MAX_PATH), MAX_PATH); file.ReleaseBuffer(); if (PathIsDirectory(file)) continue; // no duplicates LVFINDINFO lvInfo; lvInfo.flags = LVFI_STRING; lvInfo.psz = file; if (FindItem(&lvInfo, -1) != -1) continue; int index = InsertItem(GetItemCount(), file); if (index >= 0) SetCheck(index, true); } DragFinish(hDropInfo); SetColumnWidth(0, LVSCW_AUTOSIZE); }
void CNotesDlg::check_date_input( CString &DateString ) { int iIsSlash; int iIsNum; int status = ABP_FAILURE; int size = 0; TCHAR CurrentChar; if( !DateString.IsEmpty() ) { CurrentChar = DateString.GetAt((size = DateString.GetLength() - 1)); if( (iIsNum = isdigit( (int)CurrentChar)) || !(iIsSlash = strncmp( (LPCTSTR)&CurrentChar, (LPCTSTR)"/", 1)) ) { if( ((iIsNum >= 0) && (iIsNum <= 9)) || (!iIsSlash ) ) status = ABP_SUCCESS; } if( status == ABP_FAILURE ) { Beep( 400, 75 ); DateString.GetBufferSetLength( size ); } } return; }
void AFXAPI DDX_CBString(CDataExchange* pDX, int nIDC, CString& value) { HWND hWndCtrl = pDX->PrepareCtrl(nIDC); if (pDX->m_bSaveAndValidate) { // just get current edit item text (or drop list static) int nLen = ::GetWindowTextLength(hWndCtrl); if (nLen > 0) { // get known length ::GetWindowText(hWndCtrl, value.GetBufferSetLength(nLen), nLen+1); } else { // for drop lists GetWindowTextLength does not work - assume // max of 255 characters ::GetWindowText(hWndCtrl, value.GetBuffer(255), 255+1); } value.ReleaseBuffer(); } else { // set current selection based on model string if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)(LPCTSTR)value) == CB_ERR) { // just set the edit text (will be ignored if DROPDOWNLIST) AfxSetWindowText(hWndCtrl, value); } } }
void AFXAPI DDX_LBString(CDataExchange* pDX, int nIDC, CString& value) { HWND hWndCtrl = pDX->PrepareCtrl(nIDC); if (pDX->m_bSaveAndValidate) { int nIndex = (int)::SendMessage(hWndCtrl, LB_GETCURSEL, 0, 0L); if (nIndex != -1) { int nLen = (int)::SendMessage(hWndCtrl, LB_GETTEXTLEN, nIndex, 0L); ::SendMessage(hWndCtrl, LB_GETTEXT, nIndex, (LPARAM)(LPVOID)value.GetBufferSetLength(nLen)); } else { // no selection value.Empty(); } value.ReleaseBuffer(); } else { // set current selection based on data string if (::SendMessage(hWndCtrl, LB_SELECTSTRING, (WPARAM)-1, (LPARAM)(LPCTSTR)value) == LB_ERR) { // no selection match TRACE0("Warning: no listbox item selected.\n"); } } }
// CString overload of above function void ConvertWordToASCIICS(CString& csString, const WORD wValue) { char*p = csString.GetBufferSetLength(MAX_WORDHEXSTRINGLENGTH); ConvertWordToASCII(p, wValue); csString.ReleaseBuffer(); }
void CMatrixDoc::TurnString(CString &sdata) { CString * pVal=NULL; int num=GetVariableNum(sdata,pVal); int debug=num; for(int i=0;i<num;i++) { sdata.Replace(pVal[i],"@"); } CString temp=sdata; num=0; for(int j=0;j<lstrlen(temp);j++) { if(temp[j]!=TCHAR(' ')) { sdata.SetAt(num,temp[j]); num++; } else continue; } if(num<lstrlen(temp)) { sdata.SetAt(num,'\0'); sdata.GetBufferSetLength(lstrlen(sdata)); } if(pVal!=NULL) delete []pVal; }
BOOL CUtils::IsWin8() { static BOOL g_bFirst = TRUE; static BOOL g_bResult = FALSE; if (g_bFirst) { OSVERSIONINFO osif = { 0 }; osif.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osif); if(osif.dwMajorVersion == 6 && osif.dwMinorVersion == 2) { WCHAR szNtoskrnl[MAX_PATH] = {}; SHGetSpecialFolderPath(NULL, szNtoskrnl, CSIDL_SYSTEM, FALSE); PathAppend(szNtoskrnl, L"ntoskrnl.exe"); CString strVersion; CCommonAlgorithm::GetFileVer(szNtoskrnl, strVersion.GetBufferSetLength(256), strVersion.GetLength()); strVersion.Trim(); if (strVersion.Find(L"6.2") == 0) { g_bResult = TRUE; } } g_bFirst = FALSE; } return g_bResult; }
CString CApplicationImpl::GetOptionsPath(LPCTSTR szSubKey) { CString csResult; ::PathCombine(csResult.GetBufferSetLength(MAX_PATH), APP_OPTION_PATH, szSubKey); csResult.ReleaseBuffer(); return csResult; }
CString formatForSingleLine(LPCTSTR szIn, char cCommentChar) { CString s; size_t length = strlen(szIn); char* x = s.GetBufferSetLength(length+1); const char* p = szIn; while(*p) { if(*p=='\r' || *p=='\n') { if(*(x-1) !=' ') // don't want more than one space to appear *(x++) =' '; } else if(*p==cCommentChar) // don't show in-line comments { while(*p && *p!='\r' && *p!='\n') // skip to end of line { ++p; if(!*p) // don't want to swallow up terminator { --p; break; } } } else *(x++) =*p; ++p; } *x = '\0'; s.ReleaseBuffer(); return s; }
CString GetExecutableFolder() { // get folder of executing file CString path; GetModuleFileName(NULL, path.GetBufferSetLength(MAX_PATH), MAX_PATH); return path.Left(path.ReverseFind('\\')+1); }
BOOL ReadFileAsString(LPCTSTR szFilePath, CString& strData) { LPBYTE pData = NULL; DWORD dwLength = 0; if(!Util::ReadFile(szFilePath, pData, dwLength)) return FALSE; if(dwLength >= 2 && memcmp(details::g_byUnicodeBOM, pData, 2) == 0) { LPTSTR pDataMem = strData.GetBufferSetLength(dwLength - 2); memcpy(pDataMem, pData, dwLength - 2); strData.ReleaseBuffer(); } else if(dwLength >= 3 && memcmp(details::g_byUtf8BOM, pData, 3) == 0) { if(!details::ToUnicode(pData + 3, dwLength - 3, CP_UTF8, strData)) return FALSE; } else { if(!details::ToUnicode(pData, dwLength, CP_ACP, strData)) return FALSE; } return TRUE; }
void CSqlCursor::getExecutionPlan(CString& rPlan, int nMaxSize) { ASSERT(isConnected()); if (::sqlexp(*this, (SQLTDAP)rPlan.GetBufferSetLength(nMaxSize), (SQLTDAL)nMaxSize)) THROW(new CSqlCsrException(*this)); rPlan.ReleaseBuffer(); }
BOOL CResizableLayout::LikesClipping(HWND hWnd) { // check child type CString st; GetClassName(hWnd, st.GetBufferSetLength(MAX_PATH), MAX_PATH); st.ReleaseBuffer(); st.MakeUpper(); DWORD style = GetWindowLong(hWnd, GWL_STYLE); // skip windows that wants background repainted if (st == "BUTTON" && (style & 0x0FL) == BS_GROUPBOX) return FALSE; if (st == "STATIC") { switch (style & SS_TYPEMASK) { case SS_BLACKRECT: case SS_GRAYRECT: case SS_WHITERECT: case SS_ETCHEDHORZ: case SS_ETCHEDVERT: break; case SS_ICON: case SS_ENHMETAFILE: if (style & SS_CENTERIMAGE) return FALSE; break; default: return FALSE; } } return TRUE; }
/*比對*/ void CModel::OnOK() { void* MilModel; CString path; DOUBLE OffsetX = 0; DOUBLE OffsetY = 0; MilModel = malloc(sizeof(int)); GetModuleFileName(NULL, path.GetBufferSetLength(MAX_PATH + 1), MAX_PATH); path.ReleaseBuffer(); int pos = path.ReverseFind('\\'); path = path.Left(pos) + _T("\\Temp\\"); LPTSTR lpszText = new TCHAR[path.GetLength() + 1]; lstrcpy(lpszText, path); int iSelPos = m_ModelList.GetNextItem(-1, LVIS_SELECTED); #ifdef PRINTF _cprintf("%d", iSelPos); #endif #ifdef VI if (iSelPos != -1) { VI_LoadModel(MilModel, lpszText, AllModelName.at(iSelPos)); VI_SetPatternMatch(MilModel, 1, 1, 80, 0, 360); VI_FindMark(MilModel, OffsetX, OffsetY); VI_ModelFree(MilModel); free(MilModel); } #endif #ifdef MOVE MO_Do3DLineMove((LONG)OffsetX, (LONG)OffsetY, 0, 30000, 100000, 6000); #endif //CDialogEx::OnOK(); }
void __cdecl zdlTrace(LPCTSTR apszFormat, ...) { va_list args; va_start(args, apszFormat); va_list argListSave = args; int lnDataLength = GetFormatLength(apszFormat,args); CString lstrTempData; LPCTSTR lpszBuffer = lstrTempData.GetBufferSetLength(lnDataLength); _vstprintf((TCHAR *)lpszBuffer, apszFormat, argListSave); lstrTempData.ReleaseBuffer(lnDataLength); #ifdef _UNICODE ::OutputDebugStringW(lstrTempData.GetBuffer(0)); #else ::OutputDebugStringA(lstrTempData.GetBuffer(0)); #endif lstrTempData.ReleaseBuffer(); va_end(argListSave); va_end(args); }
static void PerformCommonGitPathCleanup(CString &path) { path.Trim(L"\"'"); if (path.Find(L"%") >= 0) { int neededSize = ExpandEnvironmentStrings(path, nullptr, 0); CString origPath(path); ExpandEnvironmentStrings(origPath, path.GetBufferSetLength(neededSize), neededSize); path.ReleaseBuffer(); } path.Replace(L"/", L"\\"); path.Replace(L"\\\\", L"\\"); if (path.GetLength() > 7 && path.Right(7) == _T("git.exe")) path = path.Left(path.GetLength() - 7); path.TrimRight(L"\\"); // prefer git.exe in cmd-directory for Git for Windows based on msys2 if (path.GetLength() > 12 && (path.Right(12) == _T("\\mingw32\\bin") || path.Right(12) == _T("\\mingw64\\bin")) && PathFileExists(path.Left(path.GetLength() - 12) + _T("\\cmd\\git.exe"))) path = path.Left(path.GetLength() - 12) + _T("\\cmd"); // prefer git.exe in bin-directory, see https://github.com/msysgit/msysgit/issues/103 if (path.GetLength() > 5 && path.Right(4) == _T("\\cmd") && PathFileExists(path.Left(path.GetLength() - 4) + _T("\\bin\\git.exe"))) path = path.Left(path.GetLength() - 4) + _T("\\bin"); }
void git::GetLastComment(LPCTSTR szWorkingDir, CString &sComment) { CString sOriginalDir; GetCurrentDirectory(2000, sOriginalDir.GetBufferSetLength(2000)); SetCurrentDirectory(szWorkingDir); CString sOutputFile = config::szDump; sOutputFile.Replace("../", "../../"); //workaround CString sCommand; sCommand.Format("git log -1 >> %s", sOutputFile); RUN(sCommand); CStdioFile file; if (file.Open(sOutputFile, CFile::modeRead | CFile::shareDenyNone, NULL)) { file.ReadString(sComment); file.ReadString(sComment); file.ReadString(sComment); file.ReadString(sComment); file.ReadString(sComment); sComment.TrimLeft(); file.Close(); } // sComment = "vss2git: 12345"; ::DeleteFile(sOutputFile); SetCurrentDirectory(sOriginalDir); }
BOOL CLicensePg::OnInitDialog() { CCePropertyPage::OnInitDialog(); // load the license CString license; CString fileName; fileName.Format(_T("%s\\%s"), Config.InstallDir, _T("COPYING")); HANDLE hFile = CreateFile(fileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) { char buffer[BUFFER_SIZE]; DWORD read; while (ReadFile(hFile, buffer, BUFFER_SIZE, &read, NULL) && read > 0) { int len = MultiByteToWideChar(CP_UTF8, 0, buffer, read, NULL, 0); CString s; LPTSTR lpStr = s.GetBufferSetLength(len); MultiByteToWideChar(CP_UTF8, 0, buffer, read, lpStr, len); license += s; } license.Replace(_T("\n"), _T("\r\n")); m_ctlLicense.SetWindowText(license); CloseHandle(hFile); } m_ctlLicense.SetReadOnly(); return TRUE; }
void git::Commit(LPCTSTR szOutputFile, LPCTSTR szWorkingDir, LPCTSTR szTime, LPCTSTR szUser, LPCTSTR szEmail, LPCTSTR szComment) { CString sOriginalDir; GetCurrentDirectory(2000, sOriginalDir.GetBufferSetLength(2000)); SetCurrentDirectory(szWorkingDir); CString sOutputFile = szOutputFile; sOutputFile.Replace("../", "../../"); //workaround CString sCommand; sCommand.Format("git add -A >> %s", sOutputFile); RUN(sCommand); sCommand.Format("git config user.name %s >> %s", szUser, sOutputFile); RUN(sCommand); sCommand.Format("git config user.email %s >> %s", szEmail, sOutputFile); RUN(sCommand); sCommand.Format("env GIT_AUTHOR_DATE=\"%s 0 %s\" git commit -m '%s' >> %s", szTime, config::szTimeZone, szComment, sOutputFile); RUN(sCommand); SetCurrentDirectory(sOriginalDir); }
void git::Create(LPCTSTR szOutputFile, LPCTSTR szWorkingDir, LPCTSTR szTime, LPCTSTR szUser, LPCTSTR szEmail, LPCTSTR szComment) { CString sOriginalDir; GetCurrentDirectory(2000, sOriginalDir.GetBufferSetLength(2000)); SetCurrentDirectory(szWorkingDir); if (!file::DoesFileExist(".git")) { CString sOutputFile = szOutputFile; sOutputFile.Replace("../", "../../"); //workaround CString sCommand; sCommand.Format("git init >> %s", sOutputFile); RUN(sCommand); sCommand.Format("ECHO. >> %s", sOutputFile); RUN(sCommand); sCommand.Format("ECHO. >> %s", sOutputFile); RUN(sCommand); git::Commit(szOutputFile, szWorkingDir, szTime, szUser, szEmail, szComment); } SetCurrentDirectory(sOriginalDir); }
bool SourceEdit::SaveFile(CFile* file) { // Get the contents of the document as UTF-8 CallEdit(SCI_CONVERTEOLS,SC_EOL_LF); int len = (int)CallEdit(SCI_GETLENGTH); CString utfText; LPSTR utfPtr = utfText.GetBufferSetLength(len+1); CallEdit(SCI_GETTEXT,len+1,(sptr_t)utfPtr); utfText.ReleaseBuffer(); // Write out the document contents bool success = true; try { file->Write(utfText,utfText.GetLength()); CallEdit(SCI_SETSAVEPOINT); } catch (CException* ex) { ex->Delete(); success = false; } CFileStatus status; if (file->GetStatus(status)) m_fileTime = status.m_mtime; return success; }
void SourceEdit::OpenFile(CFile* file) { int utfLen = (int)file->GetLength(); // Read in the file as UTF-8 CString utfText; LPSTR utfPtr = utfText.GetBufferSetLength(utfLen); file->Read(utfPtr,utfLen); utfText.ReleaseBuffer(utfLen); // Check for a UTF-8 BOM if (utfText.GetLength() >= 3) { if (utfText.Left(3) == "\xEF\xBB\xBF") utfText = utfText.Mid(3); } CallEdit(SCI_SETTEXT,0,(sptr_t)(LPCSTR)utfText); CallEdit(SCI_EMPTYUNDOBUFFER); CallEdit(SCI_SETSAVEPOINT); CFileStatus status; if (file->GetStatus(status)) m_fileTime = status.m_mtime; }
// Called by the parser. Handle the data for the item we are currently handling. void CPrefElement::characterData(const char* s, int len) { if (!m_bPrefOpen) return; if (m_strCurrentTag.CompareNoCase("VALUE") == 0) { char* p = m_strPrefValue.GetBufferSetLength(len); memcpy(p, s, len); m_strPrefValue.ReleaseBuffer(); m_strPrefValue.TrimLeft("\r\n"); m_strPrefValue.TrimRight("\r\n"); // Done with the data for this tag. m_strCurrentTag = ""; } else if (m_strCurrentTag.CompareNoCase("LOCKED") == 0) { CString tmp; char* p = tmp.GetBufferSetLength(len); memcpy(p, s, len); tmp.ReleaseBuffer(); tmp.TrimLeft("\r\n"); tmp.TrimRight("\r\n"); m_bLocked = (tmp.CompareNoCase("true") == 0); // Done with the data for this tag. m_strCurrentTag = ""; } else if (m_strCurrentTag.CompareNoCase("REMOTEADMIN") == 0) { CString tmp; char* p = tmp.GetBufferSetLength(len); memcpy(p, s, len); tmp.ReleaseBuffer(); tmp.TrimLeft("\r\n"); tmp.TrimRight("\r\n"); m_bRemoteAdmin = (tmp.CompareNoCase("true") == 0); // Done with the data for this tag. m_strCurrentTag = ""; } }
bool ProfileDlg::SetAutoCheckProfile(bool autoStart) { CString str = _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run"); CRegKey regKey; if(regKey.Open(HKEY_CURRENT_USER, str, KEY_SET_VALUE) == ERROR_SUCCESS) { if(autoStart) { //get the path of our program CString name = AfxGetApp()->m_pszExeName; name +=_T(".exe"); HMODULE hmod = GetModuleHandle(name); CString path; DWORD pathLen = ::GetModuleFileName( hmod, path.GetBufferSetLength(MAX_PATH+1), MAX_PATH); path.ReleaseBuffer( pathLen ); regKey.SetValue(path + _T(" /check"), _T("xp-AntiSpy Profile Check")); } else regKey.DeleteValue(_T("xp-AntiSpy Profile Check")); regKey.Close(); return true; } return false; }