本文整理汇总了C++中atl::CString类的典型用法代码示例。如果您正苦于以下问题:C++ CString类的具体用法?C++ CString怎么用?C++ CString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RegisterComDLL
bool RegisterComDLL(HINSTANCE hin,LPCTSTR dll)
{
TCHAR curpath[MAX_PATH];
GetModuleFileName( hin, curpath, MAX_PATH );
PathRemoveFileSpec(curpath);
ATL::CString file;
file += "regsvr32 \"";
file += curpath;
file += "\\";
file += dll;
file += "\" /s";
STARTUPINFO si={0};
si.cb = sizeof(si);
PROCESS_INFORMATION pi={0};
if(!CreateProcess( NULL,(LPWSTR)file.GetString(), NULL,NULL,FALSE,0, NULL,NULL,&si, &pi ))
{
DebugOutF(filelog::log_error,"CreateProcess failed with %d",GetLastError() );
return false;
}
WaitForSingleObject(pi.hProcess,-1);
DWORD exitcode = 0;
GetExitCodeProcess(pi.hProcess,&exitcode);
if(pi.hProcess)CloseHandle(pi.hProcess);
if(pi.hThread)CloseHandle(pi.hThread);
return exitcode == 0;
}
示例2: InitPlugins
///process based init
/// todo - destructor order(I am not sure if it is correct!!)
bool PluginMng::InitPlugins(){
if (plugins_.empty()){
LoadPlugins();
uuiterator vb=plugins_.begin(),ve=plugins_.end();
for (uuiterator i=vb;i!=ve;++i){
uuplugin* p= *i;
CRegKey crk;
long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE);
if (rk==ERROR_SUCCESS){
DWORD i=0;
ATL::CString menuid;
menuid.Format(_T("%d"),p->menuwID_);
if (crk.QueryDWORDValue(menuid,i)==ERROR_SUCCESS){
p->enabled_ = false;
}
}
if (p->enabled_){
p->init();
}else{
disabled_plugins_.push_back(p);
}
}
fillpartswidth();
}
return true;
}
示例3: readInt
int CSetProxServer::readInt(ATL::CString str)
{
int nValue = 0;
// if (str.Compare(PROX_SERVER_TYPE_IE) == 0)
// {
// nValue = 1;
// }
if (str.Compare(PROX_SERVER_TYPE_NONE) == 0)
{
nValue = 0;
}
else if (str.Compare(PROX_SERVER_TYPE_HTTP) == 0)
{
nValue = 1;
}
else if (str.Compare(PROX_SERVER_TYPE_SOCK) == 0)
{
nValue = 2;
}
else if (str.Compare(PROX_SERVER_VERIFY_NO) == 0)//验证过程
{
nValue = 0;
}
else if (str.Compare(PROX_SERVER_VERIFY_YES) == 0)
{
nValue = 1;
}
else
{
nValue = -1;
}
return nValue;
}
示例4: OnHBarSearchPrev
LRESULT CH_HBarWnd::OnHBarSearchPrev(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
if(newpage){
return 0;
}
CComBSTR search_words = NULL;
m_BandEditCtrl.GetWindowText(&search_words);
ATL::CString sw = search_words.m_str;
if(sw.IsEmpty()){
return 0;
}
newpage = FALSE;
if(currentRange2==NULL){
CComQIPtr<IHTMLBodyElement,&IID_IHTMLBodyElement> bodyElement(body);
if(FAILED(bodyElement->createTextRange(¤tRange2)) && currentRange2==NULL){return 0;}
}
VARIANT_BOOL bSuccess;
long t=0;
if(wParam == HBAR_SEARCHPREVFAILED && lParam==HBAR_SEARCHPREVFAILED){//at the beginning
CComQIPtr<IHTMLBodyElement,&IID_IHTMLBodyElement> bodyElement(body);
if(FAILED(bodyElement->createTextRange(¤tRange2)) && currentRange2==NULL){return 0;}
}else{
currentRange2->setEndPoint(_T("EndToStart"),currentRange);
currentRange2->moveEnd(_T("Character"),-1*search_words.Length(),&t);
}
DWORD flag = (m_case.GetCheck()==BST_UNCHECKED?0:FINDTEXT_MATCHCASE);
if(currentRange2!=NULL && SUCCEEDED(currentRange2->findText(search_words,-1,flag,&bSuccess)) && bSuccess==VARIANT_TRUE){
int a=0;
if(FAILED(currentRange2->select())){a=1;}
currentRange->setEndPoint(_T("StartToEnd"),currentRange2);
if(a==1){::PostMessage(m_hWnd, WM_HBAR_SEARCH_PREV, 0, 0);}
}else{
::PostMessage(m_hWnd, WM_HBAR_SEARCH_PREV, HBAR_SEARCHPREVFAILED, HBAR_SEARCHPREVFAILED);
}
return 0;
}
示例5: CheckIp
BOOL CSetProxServer::CheckIp( ATL::CString& str )//检查IP地址是否合法
{
LPCWSTR lpIpString = str.GetBuffer(-1);
str.ReleaseBuffer(-1);
int nStrLen = 0;
int nDotCount = 0;
nStrLen = wcslen(lpIpString);
if((nStrLen > 15) || (nStrLen < 7))
return FALSE;
for(int i=0; i < nStrLen; ++i)
{
if( lpIpString[i] == L'.' )
{
if( (lpIpString[i+1] == '.') || (i==0) || (i==nStrLen-1))
return FALSE;
nDotCount++;
continue;
}
if( (lpIpString[i] < L'0') || (lpIpString[i] > L'9') )
return FALSE;
}
if( nDotCount == 3)
{
if(inet_addr(CW2A(str.GetBuffer(-1))) != INADDR_NONE)
{
return TRUE;
}
}
return FALSE;
}
示例6: TimeToString
//////////////////////////////////////////////////////////////////////////
//时间与字符串互相转换函数
ATL::CString GlobeFuns::TimeToString(const CTime &t)
{
ATL::CString strDateTime;
strDateTime.Format("%d-%02d-%02d %02d:%02d:%02d",
t.GetYear(), t.GetMonth(), t.GetDay(),
t.GetHour(), t.GetMinute(), t.GetSecond());
return strDateTime;
}
示例7: GetStringValue
ATL::CString GetStringValue(CRegKey& rk, const ATL::CString& valueName)
{
ATL::CString result;
DWORD dwLen = 1024;
rk.QueryStringValue(valueName, result.GetBuffer(dwLen), &dwLen);
result.ReleaseBuffer();
return result;
}
示例8: OnDropFiles
void MainDialog::OnDropFiles(HDROP hdrop)
{
ATL::CString path;
UINT len = DragQueryFile(hdrop, 0, NULL, 0);
char *pch = path.GetBufferSetLength(len);
if(DragQueryFile(hdrop, 0, pch, len + 1)) {
m_xml = pch;
DoDataExchange(false, IDC_XML);
EnableDlgItem(IDC_START);
}
DragFinish(hdrop);
}
示例9:
PluginMng::~PluginMng(){
for (int i=0;i<(int)plugins_.size();i++){
uuplugin* uup = plugins_.at(i);
CRegKey crk;
long rk=crk.Open(HKEY_LOCAL_MACHINE, _6bees_const::kplugindisabled, KEY_READ|KEY_WRITE);
if (rk==ERROR_SUCCESS){
ATL::CString menuid;
menuid.Format(_T("%d"),uup->menuwID_);
if(uup->enabled_){
crk.DeleteValue(menuid);
}else{
crk.SetDWORDValue(menuid,1);
}
}
}
}
示例10: thread_getalexa
UINT WINAPI alexa::thread_getalexa(LPVOID p){
alexainfo* pas = static_cast<alexainfo*>(p);
int alexarank = 0;
std::wstring hostname(pas->hostname.c_str());
if(url2alexa.find(hostname)==url2alexa.end()){
alexarank = GetAlexaRank(pas->hostname.c_str());
url2alexa[hostname] = alexarank;
}else{
alexarank = url2alexa[hostname];
}
ATL::CString stralexa;
stralexa.Format(L"%d",alexarank);
pas->alexaptr->tid2panetext_[pas->tid] = stralexa;
if(IsWindow(pas->psb->m_hWnd))
pas->psb->SetText(pas->paneid,stralexa);
return 0;
}
示例11: TimeToString
HRESULT TimeToString( __time64_t nTime, ATL::CString& strTime )
{
ATL::CTime time(nTime);
strTime.Format( TEXT("%d %d %d %d:%d:%d"),
time.GetYear(), time.GetMonth(),
time.GetDay(), time.GetHour(),
time.GetMinute(),time.GetSecond());
return S_OK;
}
示例12: GetCurrentThreadId
bool alexa::OnNavigateComplete2(int paneid,const wchar_t* url){
C6BeeMenuStatusBar* pSB = GetC6BeeMenuStatusBarPtr();
if (pSB==NULL){
return false;
}
ATL::CString myurl = url;
if(myurl.Find(_T("http://"))!=0){
return false;
}
int cut=myurl.Find(_T("/"),8);
if (cut<0){return false;}
myurl.Truncate(cut);
alexa_info.paneid = paneid;
alexa_info.hostname = myurl;
alexa_info.psb = pSB;
alexa_info.tid = GetCurrentThreadId();
alexa_info.alexaptr = this;
::_beginthreadex(NULL,0,thread_getalexa,
(LPVOID)&alexa::alexa_info,0,NULL);
return true;
}
示例13: OnCtlColorEdit
LRESULT CH_HBarWnd::OnCtlColorEdit(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
HDC hdcEdit = (HDC) wParam; // handle to display context
HWND hwndEdit = (HWND) lParam; // handle to static control
if (hwndEdit==m_BandEditCtrl.m_hWnd)
{
CComBSTR search_words = NULL;
m_BandEditCtrl.GetWindowText(&search_words);
ATL::CString sw = search_words.m_str;
if(sw.IsEmpty() && bkcolor!=kGreen){
bkcolor = kGreen;
m_hBrush = ::CreateSolidBrush(bkcolor);
RECT rc;
m_BandEditCtrl.GetClientRect(&rc);
m_BandEditCtrl.InvalidateRect(&rc,TRUE);
}
if (m_hBrush == NULL)
m_hBrush = ::CreateSolidBrush(bkcolor);
SetBkColor(hdcEdit,bkcolor);
SetTextColor(hdcEdit, RGB(0,20,245));
return ((LRESULT) m_hBrush);
}
return 0;
}
示例14: OnClicked_BtnOK
LRESULT CSiteSelectedBoxWnd::OnClicked_BtnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
ATL::CString strName;
m_ctrlSiteCombo.GetLBText(m_ctrlSiteCombo.GetCurSel(), strName);
map<TSTLSTRING, TSTLSTRING>::iterator iterSite = m_SiteMap.find(strName.GetString());
if(iterSite == m_SiteMap.end())
{
MessageBox(TEXT("您没有选择站点?"), TEXT("提示"), MB_OK|MB_ICONINFORMATION);
bHandled = TRUE;
return 0;
}
try
{
ConfigureManager::GetInstance().SetSettingValue(TEXT("sitename"), iterSite->second);
ConfigureManager::GetInstance().Save();
}
catch(Exception& error)
{
MessageBox(error.GetMessage().c_str(), TEXT("错误"), MB_OK|MB_ICONERROR);
}
DestroyWindow();
if(!OnSelected.m_EventList.empty())
{
Event< SiteSelected >::EventIterator iter;
for( iter = OnSelected.m_EventList.begin();
iter != OnSelected.m_EventList.end();
++iter )
{
InvokeEvent(true, iterSite->second);
}
}
bHandled = TRUE;
return 0;
}
示例15: WSCoCreateDotNetInstancePtr
IUnknownPtr GenericCLRLoader::WSCoCreateDotNetInstancePtr(const CLSID& clsid)
{
LPOLESTR szClsid;
HRESULT hr = StringFromCLSID(clsid, &szClsid);
if (FAILED(hr))
throw _com_error(hr);
ATL::CString sClsid = szClsid;
CoTaskMemFree(szClsid);
CRegKey rkCLSID;
hr = rkCLSID.Open(HKEY_CLASSES_ROOT, L"CLSID\\" + sClsid + L"\\InprocServer32", KEY_READ);
if (hr != ERROR_SUCCESS)
throw _com_error(HRESULT_FROM_WIN32(hr));
ATL::CString sAssembly = GetStringValue(rkCLSID, L"Assembly");
ATL::CString sClass = GetStringValue(rkCLSID, L"Class");
ATL::CString sCodeBase = GetStringValue(rkCLSID, L"CodeBase");
if (sAssembly.GetLength() == 0 || sClass.GetLength() == 0 || sCodeBase.GetLength() == 0)
throw _com_error(REGDB_E_CLASSNOTREG);
ATL::CString dllPath;
ATL::CString strFilePrefix(_T("file:///"));
if (sCodeBase.Left(strFilePrefix.GetLength()).MakeLower() == strFilePrefix)
{
dllPath = sCodeBase.Mid(strFilePrefix.GetLength()); // discard 'file:///'
}
else
{
dllPath = sCodeBase;
}
IUnknownPtr result;
hr = TheInstance()->CreateCOMObject(dllPath, sAssembly, sClass, &result);
if (FAILED(hr))
throw _com_error(hr);
return result;
}