本文整理汇总了C++中W2A函数的典型用法代码示例。如果您正苦于以下问题:C++ W2A函数的具体用法?C++ W2A怎么用?C++ W2A使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了W2A函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KL1_RegisterModule
// registers module for start during system boot
int KL1_RegisterModule (const WCHAR *name, const WCHAR* path)
{
HKEY hkey;
int err = KL1_OpenHKey(hkey);
if (err != KL1_SUCC)
{
return err;
}
if (g_os == KL1_OS_9X)
{
USES_CONVERSION;
const char * sname = W2A(name);
const char * spath = W2A(path);
if (RegSetValueExA(hkey, sname, 0, REG_SZ, (CONST BYTE*)spath, (DWORD)strlen(spath) + 1) != ERROR_SUCCESS)
{
KL1_CloseHKey(hkey);
return KL1_ERR;
}
}
else
{
if (RegSetValueExW(hkey, name, 0, REG_SZ, (CONST BYTE*)path, (DWORD)((wcslen(path) + 1)*sizeof(WCHAR))) != ERROR_SUCCESS)
{
KL1_CloseHKey(hkey);
return KL1_ERR;
}
}
KL1_CloseHKey(hkey);
return KL1_SUCC;
}
示例2: KL1_IsModuleRegistered
// checks if module is registered
int KL1_IsModuleRegistered (const WCHAR *name, const WCHAR* path)
{
HKEY hkey;
int err = KL1_OpenHKey(hkey);
if (err != KL1_SUCC)
{
return err;
}
if (g_os == KL1_OS_9X)
{
USES_CONVERSION;
const char * sname = W2A(name);
char szPath[MAX_PATH];
DWORD dwPathSize = sizeof(szPath);
if (RegQueryValueExA(hkey, sname, 0, 0, (BYTE*)szPath, &dwPathSize) != ERROR_SUCCESS)
{
KL1_CloseHKey(hkey);
return KL1_FALSE;
}
if (path)
{
const char * spath = W2A(path);
if (strcmp(szPath, spath) != 0)
{
KL1_CloseHKey(hkey);
return KL1_FALSE;
}
}
}
else
{
WCHAR wszPath[MAX_PATH];
DWORD dwPathSize = sizeof(wszPath);
if (RegQueryValueExW(hkey, name, 0, 0, (BYTE*)wszPath, &dwPathSize) != ERROR_SUCCESS)
{
KL1_CloseHKey(hkey);
return KL1_FALSE;
}
if (path)
{
if (wcscmp(wszPath, path) != 0)
{
KL1_CloseHKey(hkey);
return KL1_FALSE;
}
}
}
KL1_CloseHKey(hkey);
return KL1_TRUE;
}
示例3: GenerateError
HRESULT GenerateError (REFCLSID rClsId, REFIID riid, LPCOLESTR pcHelpFile, HRESULT hRes) {
#endif
CComBSTR strMsgLine;
DWORD dwErr = FormatMessageLine( strMsgLine, hRes, NULL );
#if defined(_DEBUG)
USES_CONVERSION;
if( dwErr ) {
LPTSTR lptMsg = NULL;
CComBSTR strMsg(L"\n---------------------- Fehler beim Erzeugen der Fehlermeldung ----------------------\n");
if( ::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwErr, 1024, (LPTSTR) &lptMsg, 0, NULL ) ) {
USES_CONVERSION;
strMsg.Append( A2W(lptMsg) );
::LocalFree(lptMsg);
if( 0x716 == dwErr ) {
strMsg.Append(L"\n----------------------------------------------------------------------------------------");
strMsg.Append( L"\nHat die Message-Ressource den Wert 1? ;-)" );
}
strMsg.Append(L"\n----------------------------------------------------------------------------------------");
_CrtDbgReport(_CRT_ASSERT, strFile, line, NULL, W2A(strMsg) );
return E_FAIL;
}
}
CComBSTR strDbgLine;
FormatDebuggerLine( strDbgLine, hRes, strFile, line, strExpr );
strDbgLine.Append( _T("\t") );
strDbgLine.Append( strMsgLine );
strDbgLine.Append( _T("\n") );
{ ATLTRACE( W2A(strDbgLine) ); }
#endif
DWORD dwHelpID = hRes;
return AtlReportError(rClsId, strMsgLine, dwHelpID, pcHelpFile, riid, hRes);
}
示例4: ConcatAttributes
std::string ConcatAttributes()
{
std::ostringstream ost;
USES_CONVERSION;
for (size_t i= 0; i < ~0; ++i)
if (const TCHAR* name= GetImageAttribName(i))
ost << W2A(name) << ' ';
else
break;
for (size_t i= 0; i < ~0; ++i)
if (const TCHAR* name= GetMetaAttribName(i))
ost << W2A(name) << ' ';
else
break;
for (size_t i= 0; i < ~0; ++i)
if (const TCHAR* name= GetFileAttribName(i))
ost << W2A(name) << ' ';
else
break;
return ost.str();
}
示例5: SysFreeString
STDMETHODIMP CFDMUploader::CreateUpload(IUploadPackage *pPkg, BOOL bDialogReq, long *pUplId)
{
if (_pwndUploads == NULL || _pwndUploads->m_pwndUploads == NULL)
return E_FAIL;
USES_CONVERSION;
vmsUploadsDll::vmsUploadPackage *p = NULL;
if (pPkg != NULL)
{
_pwndUploads->m_pwndUploads->CreateNewPackage (&p);
long lCount = 0;
pPkg->GetFileCount (&lCount);
for (long i = 0; i < lCount; i++)
{
BSTR bstr;
pPkg->GetFilePath (i, &bstr);
p->add (W2A (bstr));
SysFreeString (bstr);
}
BSTR bstr = NULL;
pPkg->get_Name (&bstr);
if (bstr != NULL)
{
p->set_name (W2A (bstr));
SysFreeString (bstr);
}
}
return _pwndUploads->m_pwndUploads->CreateUpload (p, bDialogReq, pUplId) ? S_OK : E_FAIL;
}
示例6: lock
STDMETHODIMP CSharpDelegator::put_profilerName(BSTR newVal)
{
CLock lock (g_cs);
USES_CONVERSION;
HRESULT hr=S_OK;
if(!PathFileExists(W2A(newVal)))
{
return HRESULT_FROM_WIN32(GetLastError());
}
if(hProfiler==NULL)
{
hProfiler=LoadLibrary(W2A(newVal));
if(!hProfiler)
{
hr=HRESULT_FROM_WIN32(GetLastError());
}
else
{
hr=S_OK;
}
}
else
{
hr=HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED);
}
try {SysFreeString(newVal);} catch(...){}
return hr;
}
示例7: W2A
void MaxAWDExporter::ExportCustomProps(INode *thisNode, AWDAttrElement *elem)
{
MSTR buffer;
thisNode->GetUserPropBuffer(buffer);
AWD_field_type type = AWD_FIELD_STRING;
awd_uint16 len = 0;
AWD_field_ptr ptr;
ptr.v = NULL;
ptr.str = W2A(buffer);
len = strlen(ptr.str);
if (len>0){
if (ptr.v != NULL) {
if (ns == NULL) {
// Namespace has not yet been created; ns is a class
// variable that will be created only once and then
// reused for all user attributes.
char * ns_ptr=opts->AttributeNamespace();//dont free, as this will get freed in the opts delete
ns = new AWDNamespace(ns_ptr, strlen(ns_ptr));
awd->add_namespace(ns);
}
char * thisName=W2A(_T("CustomProps"));
elem->set_attr(ns, thisName, strlen(thisName)+1, ptr, len, type);
free(thisName);
}
}
}
示例8: SysAllocString
STDMETHODIMP CTrackDataStructureProvider::RequestOptions(OptionParams *Params)
{
CComVariant varParams;
USES_CONVERSION;
try
{
_OptionParams op;
op.Init();
op->UnderlyingSymbol = SysAllocString(Params->UnderlyingSymbol);
op->Exchange = SysAllocString(Params->Exchange);
op.CopyTo(varParams);
RT_SYMBOL symbol;
ZeroMemory(&symbol, sizeof(RT_SYMBOL));
if(Params->UnderlyingSymbol)
strncpy(symbol.name,W2A(Params->UnderlyingSymbol),10);
if(Params->Exchange)
strncpy(symbol.exchange, W2A(Params->Exchange),2);
m_Client.RequestOptions(this, &symbol, varParams);
}
catch (_com_error &err)
{
return utils::ComError2ErrInfo (err,this);
}
varParams.Clear ();
return S_OK;
}
示例9: ASSERT
ErrorCode HTMLIFrameElement::Load()
{
ASSERT(0);
return 0;
#if 0
ASSERT(m_pFrameContent);
sysstring src = get_src();
if (src.Length())
{
TCHAR result[2048];
{
sysstring documentUrl = m_ownerDocument->get_url();
DWORD resultLen = sizeof(result);
InternetCombineUrl(W2A(documentUrl), W2A(src), result, &resultLen, 0);
}
CComBSTR url = A2W(result);
return m_pFrameContent->LoadSRC(CComQIPtr<IHlinkSite>(m_ownerDocument), url);
}
else
return S_FALSE;
#endif
}
示例10: ZeroMemory
/////////////////////////////////////////////////////////////////////////////
// CTrackDataStructureProvider
STDMETHODIMP CTrackDataStructureProvider::RequestStock(StockParams *Params)
{
CComVariant varParams;
USES_CONVERSION;
try
{
RT_SYMBOL symbol;
ZeroMemory(&symbol, sizeof(RT_SYMBOL));
if(Params->Stock)
strncpy(symbol.name,W2A(Params->Stock),10);
if(Params->Exchange)
strncpy(symbol.exchange, W2A(Params->Exchange),2);
_StockParams op;
op.Init();
op->Stock = Params->Stock;
op->Exchange = Params->Exchange;
op.CopyTo(varParams);
if(RT_ERR_OK == m_Client.RequestSymbol(this, &symbol, varParams))
{
}
}
catch (_com_error &err)
{
return utils::ComError2ErrInfo (err,this);
}
varParams.Clear ();
return S_OK;
}
示例11: ASSERT
BOOL vmsMetalinkFile::ReadUrlNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Url *url)
{
USES_CONVERSION;
IXMLDOMNamedNodeMapPtr spAttrs;
pNode->get_attributes (&spAttrs);
if (spAttrs == NULL)
return FALSE;
IXMLDOMNodePtr spType;
spAttrs->getNamedItem (L"type", &spType);
if (spType == NULL)
return FALSE;
COleVariant vt;
spType->get_nodeValue (&vt);
ASSERT (vt.vt == VT_BSTR);
if (vt.vt == VT_BSTR)
url->strProtocol = W2A (vt.bstrVal);
CComBSTR bstrText;
pNode->get_text (&bstrText);
if (bstrText.Length () == 0)
return FALSE;
url->strUrl = W2A (bstrText);
return TRUE;
}
示例12: GetFlashMoviesObjList
void vmsFlashHelper::GetFlashMoviesList(IHTMLDocument2Ptr spDoc, std::vector <fsString> *pslURLs, std::vector <fsString> *pslHTMLs)
{
USES_CONVERSION;
FLASHLIST vf;
GetFlashMoviesObjList (spDoc, &vf, TRUE);
IHTMLLocationPtr spLoc;
spDoc->get_location (&spLoc);
BSTR bstrHref = NULL;
spLoc->get_href (&bstrHref);
fsString strParent = W2A (bstrHref);
SysFreeString (bstrHref);
for (int i = 0; i < vf.size (); i++)
{
IDispatch* pTag = vf [i];
fsString strMovieURL;
fsString strMovieHTML;
IHTMLObjectElementPtr spObject (pTag);
if (spObject != NULL)
{
IDispatchPtr spObj;
spObject->get_object (&spObj);
IShockwaveFlashPtr spFlash (spObj);
if (spFlash != NULL)
{
BSTR bstr;
spFlash->get_Movie (&bstr);
strMovieURL = W2A (bstr);
SysFreeString (bstr);
}
}
else
{
IHTMLEmbedElementPtr spObject(pTag);
BSTR bstrSrc = NULL;
spObject->get_src(&bstrSrc);
strMovieURL = W2A (bstrSrc);
SysFreeString (bstrSrc);
}
if (pslHTMLs != NULL)
{
IHTMLElementPtr spElement (pTag);
BSTR bstr = NULL;
spElement->get_outerHTML (&bstr);
strMovieHTML = W2A (bstr);
SysFreeString (bstr);
}
pslURLs->push_back (strMovieURL);
if (pslHTMLs)
pslHTMLs->push_back (strMovieHTML);
}
}
示例13: SetValue
BOOL CRegKey::SetValue(LPCWSTR lpValueName,CStringW& strData)
{
if (IsUnicodeSystem())
return ::RegSetValueExW(m_hKey,lpValueName,0,REG_SZ,(CONST BYTE*)(LPCWSTR)strData,(DWORD)(strData.GetLength()+1)*2)==ERROR_SUCCESS;
else
return ::RegSetValueExA(m_hKey,W2A(lpValueName),0,REG_SZ,(CONST BYTE*)(LPCSTR)W2A(strData),(DWORD)strData.GetLength()+1)==ERROR_SUCCESS;
}
示例14: ZeroMemory
void CEyepatch::LoadSampleFromFile() {
USES_CONVERSION;
WCHAR szFileNameList[MAX_PATH*16] = L"";
WCHAR szPathName[MAX_PATH] = L"";
WCHAR szFileName[MAX_PATH] = L"";
OPENFILENAMEW ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn); // SEE NOTE BELOW
ofn.hwndOwner = m_hWnd;
ofn.lpstrFilter = L"Image Files\0*.jpg;*.png;*.bmp;*.dib;*.jpeg;*.pbm;*.ppm;*.pgm;*.sr;*.ras;*.tiff;*.tif\0";
ofn.lpstrFile = szFileNameList;
ofn.nMaxFile = MAX_PATH*16;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY;
ofn.lpstrDefExt = L"jpg";
if(!GetOpenFileName(&ofn)) {
return;
}
WCHAR *strPtr = szFileNameList;
wcscpy(szPathName, strPtr);
strPtr += (wcslen(strPtr) + 1);
if (wcslen(strPtr) == 0) { // only one filename selected
m_videoMarkup.OpenSampleFile(W2A(szPathName));
} else { // step through all the filenames
while(wcslen(strPtr) != 0) {
wcscpy(szFileName, szPathName);
wcscat(szFileName, L"\\" );
wcscat(szFileName, strPtr);
m_videoMarkup.OpenSampleFile(W2A(szFileName));
strPtr += (wcslen(strPtr) + 1);
}
}
}
示例15: SplitCString1
//路径|节点|子节点|属性
//C:\Documents and Settings\All Users\Application Data\Storm\config.xml
//localplayhist
//item
//url
//C:\Documents and Settings\Administrator\桌面\0812_195706.3gp
BOOL CSpecialApp::CleanStorm_Clean(int Itype,LPCTSTR lpcszAppPath)
{
CString strPath = lpcszAppPath;
g_regClean.ConvetPath(strPath);
CSimpleArray<CString> vec_String;
int iCount = SplitCString1(strPath,vec_String,'|');
if(iCount<2)
{
return FALSE;
}
TiXmlDocument xmlDoc;
//获得文件夹名称改变其属性
iCount = vec_String[0].ReverseFind('\\');
CString strTmp;
if (iCount>0)
{
strTmp = vec_String[0].Mid(0,iCount);
}
DWORD dwErrCode=0;
if(FALSE == SetFileAttributes(strTmp, FILE_ATTRIBUTE_NORMAL))
{
dwErrCode=GetLastError();
}
USES_CONVERSION;
FILE* lpFile = _tfopen(vec_String[0], _T("a+b"));
if ( lpFile != NULL )
{
xmlDoc.LoadFile(lpFile);
fclose(lpFile);
if ( xmlDoc.Error() == 0 )
{
OutputDebugString(_T("\n打开文件成功\n"));
TiXmlElement* rootNode = xmlDoc.RootElement();
if (rootNode !=NULL)
{
TiXmlElement* nodeGeneral = rootNode->FirstChildElement(W2A(vec_String[1]));
if ( nodeGeneral != NULL )
{
// rootNode->RemoveChild(nodeGeneral);
nodeGeneral->Clear();
xmlDoc.SaveFile(W2A(vec_String[0]));
}
}
}
}
return TRUE;
}