本文整理汇总了C++中std::tstring::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ tstring::c_str方法的具体用法?C++ tstring::c_str怎么用?C++ tstring::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::tstring
的用法示例。
在下文中一共展示了tstring::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TBigDataPost
int CPostData::TBigDataPost()
{
//CString sTraceBuffer;
CUrlCrack url;
if (!url.Crack(m_strUrl.c_str()))
return ERR_URLCRACKERROR;
m_hInetSession = ::InternetOpen(MS_USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (m_hInetSession == NULL)
return ERR_NETWORKERROR;
DWORD dwTimeOut = 360000;
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONNECT_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
m_hInetConnection = ::InternetConnect(m_hInetSession, url.GetHostName(), url.GetPort(), NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD)this);
if (m_hInetConnection == NULL)
{
CloseHandles();
return ERR_NETWORKERROR;
}
LPCTSTR ppszAcceptTypes[2];
ppszAcceptTypes[0] = _T("*/*");
ppszAcceptTypes[1] = NULL;
DWORD dwFlags = 0;
if( url.GetPort() == 443 )
{
dwFlags = INTERNET_FLAG_NO_CACHE_WRITE |
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_PRAGMA_NOCACHE |
INTERNET_FLAG_SECURE |
INTERNET_FLAG_IGNORE_CERT_CN_INVALID |
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
}
else if( url.GetPort() == 80 )
{
//for HTTP
dwFlags = INTERNET_FLAG_NO_CACHE_WRITE |
INTERNET_FLAG_KEEP_CONNECTION |
INTERNET_FLAG_PRAGMA_NOCACHE ;
}
m_hInetFile = HttpOpenRequest(m_hInetConnection, _T("POST"), url.GetPath(), NULL, NULL, ppszAcceptTypes, dwFlags, (DWORD)this);
if (m_hInetFile == NULL)
{
CloseHandles();
return ERR_NETWORKERROR;
}
return ERR_SUCCESS;
}
示例2: TransferDataPost
int CPostData::TransferDataPost()
{
CUrlCrack url;
if (!url.Crack(m_strUrl.c_str()))
return ERR_URLCRACKERROR;
m_hInetSession = ::InternetOpen(MONEYHUB_USERAGENT, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (m_hInetSession == NULL)
return ERR_NETWORKERROR;
DWORD dwTimeOut = 60000;
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONTROL_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_SEND_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
InternetSetOptionEx(m_hInetSession, INTERNET_OPTION_CONNECT_TIMEOUT, &dwTimeOut, sizeof(DWORD), 0);
m_hInetConnection = ::InternetConnect(m_hInetSession, url.GetHostName(), url.GetPort(), NULL, NULL, INTERNET_SERVICE_HTTP, 0, (DWORD)this);
if (m_hInetConnection == NULL)
{
CloseHandles();
return ERR_NETWORKERROR;
}
LPCTSTR ppszAcceptTypes[2];
ppszAcceptTypes[0] = _T("*/*");
ppszAcceptTypes[1] = NULL;
m_hInetFile = HttpOpenRequest(m_hInetConnection, _T("POST"), url.GetPath(), NULL, NULL, ppszAcceptTypes, INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_KEEP_CONNECTION, (DWORD)this);
if (m_hInetFile == NULL)
{
CloseHandles();
return ERR_NETWORKERROR;
}
HttpAddRequestHeaders(m_hInetFile, _T("Content-Type: application/x-www-form-urlencoded\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
HttpAddRequestHeaders(m_hInetFile, _T("User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)\r\n"), -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
TCHAR szHeaders[1024];
_stprintf_s(szHeaders, _countof(szHeaders), _T("MoneyhubUID: %s\r\n"), m_strHWID.c_str());
HttpAddRequestHeaders(m_hInetFile, szHeaders, -1, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE);
BOOL bSend = ::HttpSendRequest(m_hInetFile, NULL, 0, m_lpPostData, m_dwPostDataLength);
if (!bSend)
{
CloseHandles();
return ERR_NETWORKERROR;
}
CloseHandles();
return ERR_SUCCESS;
}
示例3: AddMediaPath
void MyLib::AddMediaPath(std::tstring &path)
{
mediaPaths.push_back(path);
if (m_pFileMonitor == NULL)
{
m_pFileMonitor = new fileMonitors(pPlayListAuto);
}
m_pFileMonitor->AddDirectory(path.c_str());
}
示例4: CreateNotesMessage
void NotesHelper::CreateNotesMessage(const std::tstring& recipients, const std::tstring& subject, StringVector& body, LNMailMessage &message)
{
LNSTATUS status = Session::Instance()->GetNotesSession().CreateMailMessage(&message);
if(NOERROR != status)
{
std::vector<char> errorbuffer(LNERROR_MESSAGE_LENGTH);
LNINT charCount = LNGetErrorMessage(status, &errorbuffer[0]);
throw CppUnitException(std::tstring(errorbuffer.begin(), errorbuffer.begin() + charCount), __LINE__, _T(__FILE__));
}
message.SendTo(Workshare::Conversions::W22LNString(recipients.c_str()));
message.SetSubject(Workshare::Conversions::W22LNString(subject.c_str()));
LNRichText rtBody;
message.GetBody(&rtBody);
for(StringVector::iterator bodyIter = body.begin(); bodyIter != body.end(); ++bodyIter)
{
rtBody.Append(Workshare::Conversions::W22LNString(bodyIter->c_str()));
}
}
示例5: Load
std::tstring Config::Load(const std::string& name, const std::tstring& entry)
{
HKEY hkey;
if (RegOpenKeyExA(RootKey(), name.c_str(), 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS)
throw truntime_error(_T("reading configuration"));
AutoDeleteKey key(hkey);
TCHAR buf[512];
DWORD type, len = sizeof(buf);
if (RegQueryValueEx(key, entry.c_str(), NULL, &type, (BYTE*) buf, &len) != ERROR_SUCCESS || type != REG_SZ)
throw truntime_error(_T("reading configuration"));
return buf;
}
示例6: Exception
void Workshare::Mail::Mapi::RemoveMessageTag(LPMESSAGE lpMessage, const std::tstring& sTag)
{
IMAPIPropPtr spMapiProp = lpMessage;
if(spMapiProp == 0)
throw Workshare::Exception(_T("Failed to extract the IID_IMAPIProp interface from lpMessage"));
LPMAPINAMEID pTagName = 0;
HRESULT hr = MAPIAllocateBuffer(sizeof(MAPINAMEID), (LPVOID*)&pTagName);
if(FAILED(hr))
throw MapiException(hr, _T("Failed to allocate MAPI memory for the tag name"));
pTagName[0].lpguid = (LPGUID)&PS_PUBLIC_STRINGS;
pTagName[0].ulKind = MNID_STRING;
_bstr_t bsTag(sTag.c_str());
pTagName[0].Kind.lpwstrName = bsTag;
LPSPropTagArray pPropTag = 0;
hr = spMapiProp->GetIDsFromNames(1, &pTagName, 0, &pPropTag);
if(FAILED(hr))
{
MAPIFreeBuffer(pTagName);
std::tostringstream error;
error << _T("Failed to determine the ID from the tag name \"") << sTag.c_str() << _T("\"") << std::ends;
throw MapiException(hr, error.str().c_str());
}
if(1 == pPropTag->cValues && PT_ERROR != PROP_TYPE(pPropTag->aulPropTag[0]))
{
spMapiProp->DeleteProps(pPropTag, 0);
}
else
{
std::tostringstream error;
error << _T("Failed to delete the message tag \"") << sTag.c_str() << _T("\"") << std::ends;
LOG_WS_INFO(error.str().c_str());
}
MAPIFreeBuffer(pPropTag);
MAPIFreeBuffer(pTagName);
}
示例7: ExtractEmail
void ExtractEmail(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, const std::tstring& subject, const std::tstring& folder)
{
if(subject.empty())
throw Workshare::ArgumentException(_T("subject"), _T("Blank subject specified for the search"));
if(folder.empty())
throw Workshare::ArgumentException(_T("folder"), _T("Invalid destination folder specified for saving of attachments"));
if(-1 == _taccess(folder.c_str(), 0))
throw Workshare::ArgumentException(_T("folder"), _T("Destination folder does not exist"));
Outlook::_MailItemPtr spEmailItem = FindEmail(spDispOutlook, spDispNameSpace, subject);
Outlook::AttachmentsPtr spAttachments = spEmailItem->Attachments;
if(spAttachments == 0)
throw Workshare::NullReferenceException(_T("Failed to get the attachments collection for the mail item"));
long attachmentCount = spAttachments->Count;
if(0 == attachmentCount)
return;
for(long index = 1; index <= attachmentCount; index++)
{
Outlook::AttachmentPtr spAttachment = spAttachments->Item(index);
//we don't handle embedded documents
Outlook::OlAttachmentType attachmentType = spAttachment->Type;
if(Outlook::olOLE == attachmentType || Outlook::olEmbeddeditem == attachmentType)
continue;
std::tstring filename(folder);
filename.append(_T("\\")).append((LPTSTR)spAttachment->FileName);
std::tstring baseFilename = GetFilenameWithoutExtension(filename);
std::tstring fileExtension = GetFileExtension(filename);
int duplicate = 1;
while(-1 != _taccess(filename.c_str(), 0))
{
duplicate++;
std::tostringstream dupFilename;
dupFilename << baseFilename << _T("(") << duplicate << _T(").") << fileExtension << std::ends;
filename = dupFilename.str().c_str();
}
HRESULT hr = spAttachment->SaveAsFile(filename.c_str());
if(FAILED(hr))
{
std::tostringstream errMsg;
errMsg << _T("Failed to save attachment ") << (LPCTSTR)spAttachment->FileName << _T(" to ") << filename << std::ends;
throw Workshare::Com::ComException(errMsg.str().c_str(), hr, spAttachment);
}
}
}
示例8: save_url
bool facebook_client::save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc)
{
NETLIBHTTPREQUEST req = {sizeof(req)};
NETLIBHTTPREQUEST *resp;
req.requestType = REQUEST_GET;
req.szUrl = const_cast<char*>(url.c_str());
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT | NLHRF_NODUMP;
req.nlc = nlc;
resp = reinterpret_cast<NETLIBHTTPREQUEST*>(CallService(MS_NETLIB_HTTPTRANSACTION,
reinterpret_cast<WPARAM>(this->parent->m_hNetlibUser), reinterpret_cast<LPARAM>(&req)));
bool ret = false;
if (resp) {
nlc = resp->nlc;
parent->debugLogA("@@@@@ Saving avatar URL %s to path %s", url.c_str(), _T2A(filename.c_str()));
// Create folder if necessary
std::tstring dir = filename.substr(0,filename.rfind('\\'));
if (_taccess(dir.c_str(), 0))
CreateDirectoryTreeT(dir.c_str());
// Write to file
FILE *f = _tfopen(filename.c_str(), _T("wb"));
if (f != NULL) {
fwrite(resp->pData,1,resp->dataLength,f);
fclose(f);
ret = _taccess(filename.c_str(), 0) == 0;
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
} else {
nlc = NULL;
}
return ret;
}
示例9: OnNewGroupMemberList
void CGroupMemberView::OnNewGroupMemberList(const std::tstring& strRoomID, std::vector<tstring>& vecMemList)
{
//刷新界面成员
if (_tcsicmp(strRoomID.c_str(), m_strRoomID.c_str()) == 0)
{
//clear first.
m_pGroupMemberList->RemoveAll();
//add new.
for (int i=0; i<vecMemList.size(); i++)
{
sFriendListItem oneFriend;
//if (mainDlg::getInstance()->GetFriendItem(vecMemList[i], oneFriend))
//{
// vector<tstring> vecProperty;
// //有可能是 我的好友 没有机构ID,调用GetDuty就会失败!
// //if(GetDuty(oneFriend.strOrgID, oneFriend.strAccount, vecProperty))
// //{
// m_pGroupMemberList->AddOneItem(oneFriend, vecProperty);
// //}
//}
//先从好友里面去找。
if (mainDlg::getInstance()->GetFriendItem(vecMemList[i], oneFriend))
{
}
else
{
//从陌生人里面去找。
sUserVCard oneVCard;
CController::Instance()->GetUserInfoMgr()->GetUserVCard(vecMemList[i], oneVCard);
oneFriend.strAccount = oneVCard.strAccount;
oneFriend.strAvatar = oneVCard.strPhotoPath.empty()? DEF_AVATAR_NOR : oneVCard.strPhotoPath;
oneFriend.strOrgID = oneVCard.strOrganization;
oneFriend.strOrgnization = oneVCard.strOrganization;
oneFriend.strShowName = oneVCard.strUserNickname;
}
//获取duty,有可能获得的是空的。
vector<tstring> vecProperty;
if(GetDuty(oneFriend.strOrgID, oneFriend.strAccount, vecProperty))
{
}
m_pGroupMemberList->AddOneItem(oneFriend, vecProperty);
}
}
}
示例10: GetProcessIdByWindow
// Get process id from window name
DWORD Injector::GetProcessIdByWindow(const std::tstring& Name)
{
// Find window
HWND MyWnd = FindWindow(NULL,Name.c_str());
if (!MyWnd)
throw std::runtime_error("Could not find window.");
// Get process ID from window
DWORD ProcID;
GetWindowThreadProcessId(MyWnd,&ProcID);
if (!ProcID)
throw std::runtime_error("Could not get process id from window.");
// Return process id
return ProcID;
}
示例11: OpenEmail
IDispatchPtr OpenEmail(IDispatchPtr spDispOutlook, IDispatchPtr spDispNameSpace, const std::tstring& entryId)
{
if(spDispOutlook == 0)
throw Workshare::ArgumentNullException(_T("spDispOutlook"), _T("Outlook Application pointer is null."));
if(spDispNameSpace == 0)
throw Workshare::ArgumentNullException(_T("spDispNameSpace"), _T("MAPI NameSpace pointer is null."));
Outlook::_ApplicationPtr spOutlook = spDispOutlook;
Outlook::_NameSpacePtr spNameSpace = spDispNameSpace;
IDispatchPtr spMailItem;
HRESULT hr = spNameSpace->raw_GetItemFromID(_bstr_t(entryId.c_str()), vtMissing, &spMailItem);
if(FAILED(hr))
throw Workshare::Com::ComException(_T("Outlook failed to open the email message"), hr, spNameSpace);
return spMailItem;
}
示例12: LoaderException
template<> unique_ptr<ID3D10Effect> ResourceService::LoadResource<ID3D10Effect>(const std::tstring& filePath)
{
ID3D10Blob* pErrorBlob;
ID3D10Effect* pEffect;
HRESULT hr = D3DX10CreateEffectFromFile(filePath.c_str(),
NULL,
NULL,
"fx_4_0",
#ifndef NDEBUG
D3D10_SHADER_DEBUG|D3D10_SHADER_SKIP_OPTIMIZATION|D3D10_SHADER_WARNINGS_ARE_ERRORS|D3D10_SHADER_PACK_MATRIX_ROW_MAJOR, //HLSL Flags: http://msdn.microsoft.com/en-us/library/windows/desktop/bb172416%28v=vs.85%29.aspx
#else
D3D10_SHADER_OPTIMIZATION_LEVEL3|D3D10_SHADER_IEEE_STRICTNESS|D3D10_SHADER_PACK_MATRIX_ROW_MAJOR,
#endif
0,
MyServiceLocator::GetInstance()->GetService<IGraphicsService>()->GetGraphicsDevice()->GetDevice(),
NULL,
NULL,
&pEffect,
&pErrorBlob,
NULL);
if(FAILED(hr))
{
tstringstream ss;
if(pErrorBlob!=nullptr)
{
char *errors = (char*)pErrorBlob->GetBufferPointer();
for(unsigned int i = 0; i < pErrorBlob->GetBufferSize(); i++)
ss<<errors[i];
OutputDebugString(ss.str().c_str());
pErrorBlob->Release();
throw LoaderException(_T("effect ") + filePath, ss.str() );
}
MyServiceLocator::GetInstance()->GetService<DebugService>()->LogDirectXError(hr, __LINE__, __FILE__);
}
return unique_ptr<ID3D10Effect>(pEffect);
}
示例13: GetLastModifiedTime
FILETIME GetLastModifiedTime(const std::tstring& fileName)
{
FILETIME OriginalCreationTime;
FILETIME OriginalLastAccessTime;
FILETIME OriginalWriteTime;
::ZeroMemory(&OriginalCreationTime, sizeof(OriginalCreationTime));
::ZeroMemory(&OriginalLastAccessTime, sizeof(OriginalLastAccessTime));
::ZeroMemory(&OriginalWriteTime, sizeof(OriginalWriteTime));
HANDLE hFile = ::CreateFile(fileName.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if(0 != hFile)
{
::GetFileTime(hFile, &OriginalCreationTime, &OriginalLastAccessTime, &OriginalWriteTime);
::CloseHandle(hFile);
}
return OriginalWriteTime;
}
示例14: ImportLycByPath
void MyLib::ImportLycByPath(std::tstring path)
{
LPCTSTR pszFolder=path.c_str();
TCHAR* curPath=new TCHAR[MAX_PATH];
_tgetcwd(curPath,MAX_PATH);
//改变当前目录
_tchdir(pszFolder);
BOOL findResult=FALSE;
WIN32_FIND_DATA findFileData;
HANDLE hFind;
hFind=::FindFirstFile(_T("*.lrc"),&findFileData);
if(hFind!=INVALID_HANDLE_VALUE){
findResult=TRUE;
while(findResult)
{
TCHAR *_findName=new TCHAR[MAX_PATH];
_tcscpy(_findName,findFileData.cFileName);
TCHAR *pathName=new TCHAR[MAX_PATH+1];
_tcscpy(pathName,pszFolder);
_tcscat(pathName,_T("\\"));
_tcscat(pathName,_findName);
//std::tstring str(pathName);
std::tstring str(pathName);
MyLib::shared()->dataPaths.push_back(str);
findResult=FindNextFile(hFind,&findFileData);
}
FindClose(hFind);
}
//回复当前目录
_tchdir(curPath);
}
示例15: ThrowNotSupported
void CDocument::ThrowNotSupported(const std::tstring fileName)
{
std::tstring msg = fileName;
msg.append(_T(" is not a valid document"));
throw Workshare::Com::ComException(fileName.c_str(), E_UNSUPPORTED_FILEFORMAT);
}