Пример #1
1
BOOL CRegKey::DeleteKey(HKEY hKey,LPCWSTR szKey)
{
	if (!IsUnicodeSystem())
		return DeleteKey(hKey,W2A(szKey));

	HKEY hSubKey;
	FILETIME ft;
	DWORD cb;
	WCHAR szSubKey[200];
	if (RegOpenKeyExW(hKey,szKey,0,
		KEY_ENUMERATE_SUB_KEYS|KEY_SET_VALUE,&hSubKey)!=ERROR_SUCCESS)
		return TRUE;	
	DebugOpenHandle(dhtRegKey,hSubKey,szKey);
	
	for(;;)
	{
		cb=400;
		if (RegEnumKeyExW(hSubKey,0,szSubKey,&cb,NULL,
			NULL,NULL,&ft)==ERROR_NO_MORE_ITEMS)
			break;
		DeleteKey(hSubKey,szSubKey);
	}
	RegCloseKey(hSubKey);
	DebugCloseHandle(dhtRegKey,hSubKey,szKey);
	RegDeleteKeyW(hKey,szKey);
	return TRUE;
}
Пример #2
0
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;
}
Пример #3
0
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);
        }
    }
}
Пример #4
0
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);
}
Пример #5
0
// 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;
}
Пример #6
0
// 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;
}
Пример #7
0
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();
}
BOOL vmsMetalinkFile::ReadHashNode(IXMLDOMNode *pNode, vmsMetalinkFile_File_Hash *hash)
{
	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)
		hash->strAlgorithm = W2A (vt.bstrVal);
	
	CComBSTR bstrText;
	pNode->get_text (&bstrText);
	if (bstrText.Length () == 0)
		return FALSE;

	hash->strChecksum = W2A (bstrText);

	return TRUE;
}
Пример #9
0
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;
}
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;
}
Пример #11
0
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;

}
Пример #12
0
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);
        }
    }
}
Пример #13
0
	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;

		}
Пример #14
0
/////////////////////////////////////////////////////////////////////////////
// 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;
}
Пример #15
0
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
}
Пример #16
0
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);
	}
}
Пример #17
0
//路径|节点|子节点|属性
//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;

}
Пример #18
0
BOOL CWmp_scrobbler::GetCurrentSong(SONG_INFO* pSong)
{
	USES_CONVERSION;
	IWMPMedia* pMedia = NULL;
	BSTR bstrValue;
	//BSTR bstrName;
	BOOL bRet = FALSE;
	long lCount = 0;
	
	if(	(m_spCore) &&
		(pSong != NULL))
	{
		m_spCore->get_currentMedia(&pMedia);
		
		if(pMedia != NULL)
		{
			pMedia->get_attributeCount(&lCount);

/*
			for(long i = 0; i <= lCount; i++)
			{
				pMedia->getAttributeName(i, &bstrName);
				pMedia->getItemInfo(bstrName, &bstrValue);
				PRINTF(DEBUG_INFO, "WMPMEDIA", "Attribute %s - value %s", W2A(bstrName), W2A(bstrValue));
			}
            // Better check for local/streaming for the future
    		pMedia->getItemInfo(L"type", &bstrValue);
*/    		

			pMedia->getItemInfo(L"Author", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strArtist, SONG_INFO_FIELD_SIZE);
            pMedia->getItemInfo(L"Title", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strTrack, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Album", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strAlbum, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Genre", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strGenre, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"Comment", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strComment, SONG_INFO_FIELD_SIZE);
			pMedia->getItemInfo(L"SourceURL", &bstrValue);
            EncodingUtils::UnicodeToUtf8(bstrValue, -1, pSong->m_strFileName, SONG_INFO_FIELD_SIZE);
			
			pMedia->getItemInfo(L"Duration", &bstrValue);
			pSong->m_nLength = atoi(W2A(bstrValue));
			pMedia->getItemInfo(L"Track", &bstrValue);
			pSong->m_nTrackNo = atoi(W2A(bstrValue));
			pMedia->getItemInfo(L"Year", &bstrValue);
			pSong->m_nYear = atoi(W2A(bstrValue));
			
			bRet = TRUE;
		}	
	}

	return bRet;
}
Пример #19
0
HRESULT CTMReceiverSrc::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)
{
	//TODO: Open the file using ffmpeg;
	USES_CONVERSION;
	AVCodecContext *pVideoCodecCtx = NULL;
	AVCodec *pVideoCodec = NULL;
	avcodec_register_all();
	av_register_all();
	avformat_network_init();

	int cch = lstrlenW(pszFileName) + 1;
	m_pFileName = new WCHAR[cch];
	if(m_pFileName != NULL)
	{
		CopyMemory(m_pFileName, pszFileName, cch*sizeof(WCHAR));
	}

	m_pFormatContext = avformat_alloc_context();
	int err = avformat_open_input(&m_pFormatContext, W2A(m_pFileName), NULL, NULL);
	if(err != 0)
	{
		return E_FAIL;
	}
	m_pFormatContext->flags |= AVFMT_FLAG_GENPTS;
	m_pFormatContext->flags |= AVFMT_GENERIC_INDEX;
	m_pFormatContext->max_index_size = 99;
	m_pFormatContext->probesize /= 3;
	m_pFormatContext->max_analyze_duration /= 3;

	if(av_find_stream_info(m_pFormatContext) < 0)
	{
		return E_FAIL;
	}

	av_dump_format(m_pFormatContext, 0, W2A(m_pFileName), false);

	for(int i=0; i<m_pFormatContext->nb_streams; i++)
	{
		if(m_pFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
		{
			m_videoStreamIndex = i;
			pVideoCodecCtx = m_pFormatContext->streams[i]->codec;
			m_resolution.width = pVideoCodecCtx->width;
			m_resolution.height = pVideoCodecCtx->height;
		}
	}

	//TODO: Start a thread to read the packet.
	m_bReadStream = TRUE;
	DWORD dwThreadId = 0;
	m_readerThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ReaderProc, (LPVOID*)this, 0, &dwThreadId);
	return S_OK;
}
Пример #20
0
void CJason::GetValuebyKey(const CString& strKey1, const CString& strKey2, CString& strValue)
{
	USES_CONVERSION;
	strValue.Empty();
	map<string, map<string, string> >::iterator it = m_mapJasonPair.find(W2A(strKey1));
	map<string, string>::iterator itJason;

	if(it != m_mapJasonPair.end())
	{
		itJason = it->second.find(W2A(strKey2));
		if(itJason != it->second.end())
			strValue.Format(_T("%S"),itJason->second.c_str());
	}
}
Пример #21
0
void CMyDrawPictureClass::OnBnClickedButtonEditpic()
{
	// TODO: 在此添加控件通知处理程序代码
	if(m_SavePicPath.IsEmpty())
	{
		::AfxMessageBox(_T("请先进行透明图处理操作!"));
		return;
	}

	wchar_t pathw[MAX_PATH] = {0};
	//::GetSystemDirectoryW(pathw,MAX_PATH);
	::GetCurrentDirectoryW(MAX_PATH,pathw);

	CString pathName=_T("");
	CString PicPath=m_SavePicPath;
	while(true)
	{
		int pos = PicPath.Find(_T("\\"));
		if(pos == -1)
			break;
		pathName +=PicPath.Left(pos+1);
		PicPath = PicPath.Right(PicPath.GetLength()-pos-1);
	}

	::SetCurrentDirectoryW(pathName);

	char path[MAX_PATH]={0};
	USES_CONVERSION;
	::strcat(path,"mspaint.exe ");
	::strcat(path,W2A(PicPath.LockBuffer()));
	::WinExec(path,SW_SHOWNORMAL);
	/////// 还原路径 //////////////
	::SetCurrentDirectoryW(pathw);
}
Пример #22
0
void main_frame::OnAuthSuccess( VARIANT *&url )
{
	USES_CONVERSION;
	LPCTSTR lpstrAddress = (LPCTSTR)url->bstrVal;

	CDuiString str(lpstrAddress);

	int pos  = -1;
	pos = str.Find('=');

	CDuiString retnCode = str.Right(str.GetLength() - pos - 1);

	m_weiboManage.GetMethod()->oauth2Code(W2A(retnCode), REDIRECT_URL , NULL);

	CWebBrowserUI *pLoginWeb = static_cast<CWebBrowserUI*>(m_PaintManager.FindControl(_T("loginWnd")));
	if (pLoginWeb)
	{
		pLoginWeb->SetVisible(false);
	}

	CLabelUI *pUnReadTimelineCount = static_cast<CLabelUI*>(m_PaintManager.FindControl(_T("unreadTimelineCount")));
	if (pUnReadTimelineCount)
	{
		m_PaintManager.SetTimer(pUnReadTimelineCount,1,1000*10);
	}
}
Пример #23
0
bool ImageHandler::LoadImage(std::shared_ptr<BackgroundImage>& bkImage)
{
	USES_CONVERSION;

	CriticalSectionLock	lock(bkImage->updateCritSec);

	if (!bkImage) return false;

		// if we're reloading, delete old bitmap and DC
	if (!bkImage->dcImage.IsNull())
	{
		bkImage->dcImage.SelectBitmap(NULL);
		bkImage->dcImage.DeleteDC();
	}

	if (!bkImage->image.IsNull()) bkImage->image.DeleteObject();

	// create new original image
	bkImage->originalImage.reset(new fipImage());

	// load background image
	if (!bkImage->originalImage->load(W2A(Helpers::ExpandEnvironmentStrings(bkImage->imageData.strFilename).c_str())))
	{
		bkImage->originalImage.reset();
		return false;
	}

	bkImage->dwOriginalImageWidth	= bkImage->originalImage->getWidth();
	bkImage->dwOriginalImageHeight	= bkImage->originalImage->getHeight();

	bkImage->originalImage->convertTo32Bits();

	return true;
}
Пример #24
0
bool NTApplicationRunning(TCHAR * strApplName)
{
	USES_CONVERSION;

	// Get the list of process identifiers.

	DWORD aProcesses[1024], cbNeeded, cProcesses;
	unsigned int i;

	std::string strAppName = _strlwr(W2A(strApplName));

	if ( !lpEnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
		return false;

	// Calculate how many process identifiers were returned.

	cProcesses = cbNeeded / sizeof(DWORD);

	// Print the name and process identifier for each process.

	for ( i = 0; i < cProcesses; i++ )
	{
		std::string strProcess = GetProcessNameAndID( aProcesses[i] );

		if( strstr( strProcess.c_str(), strAppName.c_str() ) != NULL )
		{
			// Application is running
			return true;
		}
	}

	// Application is not running
	return false;
}
Пример #25
0
std::string GetProcessNameAndID( DWORD processID )
{
	USES_CONVERSION;

	TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
	std::string strProcess;

	// Get a handle to the process.

	HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
		PROCESS_VM_READ,
		FALSE, processID );

	// Get the process name.

	if (NULL != hProcess )
	{
		HMODULE hMod;
		DWORD cbNeeded;

		if ( lpEnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) )
		{
			lpGetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
		}

		strProcess = _strlwr(W2A(szProcessName));
		// _tprintf( TEXT(_T("%s  (PID: %u)\n")), szProcessName, processID );

		CloseHandle( hProcess );
	}
	return strProcess;
}
int MaxAWDExporter::IsCombinedGeom(INode *node){
    int isCombinedGeom=0;
    BaseObject* node_bo = node->GetObjectRef();
    if((node_bo->SuperClassID() == GEN_DERIVOB_CLASS_ID) || (node_bo->SuperClassID() == WSM_DERIVOB_CLASS_ID) || (node_bo->SuperClassID() == DERIVOB_CLASS_ID ))
    {
        IDerivedObject* node_der = (IDerivedObject*)(node_bo);
        node_bo = node_der->GetObjRef();
        if (node_der!=NULL){
            int nMods = node_der->NumModifiers();
            for (int m = 0; m<nMods; m++){
                Modifier* node_mod = node_der->GetModifier(m);
                //DebugPrint("node_mod.IsEnabled() = "+node_mod->IsEnabled());
                //MSTR name=node_mod->GetName();
                MSTR className;
                node_mod->GetClassName(className);
                char * className_ptr=W2A(className);
                if (ATTREQ(className_ptr,"AWDCombinedGeom") ){
                    AWDBlockList * newGeoList = (AWDBlockList *)combinedGeosCache->Get(node_mod);
                    if (newGeoList==NULL){
                        newGeoList=new AWDBlockList();
                        combinedGeosCache->Set(node_mod,newGeoList);
                        free(className_ptr);
                        return 1;
                    }
                    free(className_ptr);
                    return 2;
                }
                free(className_ptr);
            }
        }
    }

    return 0;
}
Пример #27
0
int CLDEditTxtFile::_LoadTxtFileWithItems(CSimpleArray<CString>& arrFileItems)
{
	int nRet = -1;
	USES_CONVERSION;
	char pszFilePath[MAX_PATH] = {0};
	StringCbPrintfA(pszFilePath, sizeof(pszFilePath), "%s", W2A(m_strTxtFile));
	FILE* pFile = NULL;
	//open file
	fopen_s(&pFile, const_cast<char*>(pszFilePath), "r");
	if (NULL == pFile)
		return nRet;

	char pszFileValue[1024] = {0};
	ZeroMemory(pszFileValue, sizeof(pszFileValue));
	arrFileItems.RemoveAll();

	while(NULL != fgets(pszFileValue, sizeof(pszFileValue), pFile))
	{
		if (NULL != m_pStop && TRUE == *m_pStop)
			return nRet;

		arrFileItems.Add(CString(pszFileValue));
		ZeroMemory(pszFileValue, sizeof(pszFileValue));
	}

	if (NULL != pFile)
		fclose(pFile);
	pFile = NULL;
	nRet = arrFileItems.GetSize();

	return nRet;
}
//Show Filter in FilterGpragh
int show_filters_in_filtergraph(IGraphBuilder *pGraph){
	printf("Filters in FilterGpragh=======\n");
	USES_CONVERSION;
	IEnumFilters *pFilterEnum=NULL;
	if(FAILED(pGraph->EnumFilters(&pFilterEnum))){
		pFilterEnum->Release();
		return -1;
	}
	pFilterEnum->Reset();
	IBaseFilter * filter = NULL;
	ULONG fetchCount = 0;
	//Pin Info
	while (SUCCEEDED(pFilterEnum->Next(1, &filter, &fetchCount)) && fetchCount){
		if (!filter){
			continue;
		}
		FILTER_INFO FilterInfo;
		if (FAILED(filter->QueryFilterInfo(&FilterInfo))){
			continue;
		}
		printf("[%s]\n",W2A(FilterInfo.achName));
		filter->Release();
	}
	pFilterEnum->Release();
	printf("==============================\n");
	return 0;
}
Пример #29
0
// get message for given error
//
char* windows_format_error_string(
    unsigned long dwError, char* pszBuf, int iSize
) {
    DWORD dwRet;
    LPWSTR lpszTemp = NULL;

    dwRet = FormatMessageW(
        FORMAT_MESSAGE_ALLOCATE_BUFFER |
        FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_ARGUMENT_ARRAY,
        NULL,
        dwError,
        LANG_NEUTRAL,
        (LPWSTR)&lpszTemp,
        0,
        NULL
    );

    if (dwRet != 0) {
        // convert from current character encoding into UTF8
        std::string encoded_message = W2A(std::wstring(lpszTemp));

        // include the hex error code as well
        snprintf(pszBuf, iSize, "%s (0x%x)", encoded_message.c_str(), dwError);

        if (lpszTemp) {
            LocalFree((HLOCAL) lpszTemp);
        }
    } else {
        strcpy(pszBuf, "(unknown error)");
    }

    return pszBuf;
}
Пример #30
0
void CInProcPlugHole::UpdateImagePathForCLSID(REFCLSID rclsid)
{
	USES_CONVERSION;
	_ASSERTE(rclsid != CLSID_NULL);

	// Find a suitable image if one has not already been specified and a CLSID is available 
	// to look up in the registry for an Image subkey.
	if (strlen(achImagePath) == 0)
	{
		// The stub is being used to load a standard Dolphin image, rather than one bound 
		// up with the stub, so we have to look up the image to load in the registry
		LPOLESTR wszCLSID;
		HRESULT hr = StringFromCLSID(rclsid, &wszCLSID);
		if (SUCCEEDED(hr))
		{

			LPCSTR szCLSID = W2A(wszCLSID);
			char szKey[5+1+38+1+5+1] = "CLSID\\";
			strcat(szKey, szCLSID);
			strcat(szKey, "\\Image");
			_ASSERTE(strlen(szKey) < sizeof(szKey));
			CRegKey rKey;
			if (ERROR_SUCCESS == rKey.Open(HKEY_CLASSES_ROOT, szKey))
			{
				DWORD dwChars = _MAX_PATH;
				rKey.QueryStringValue("", achImagePath, &dwChars);
			}
			CoTaskMemFree(wszCLSID);
		}
	}
}