LRESULT CPropertyAddDialog::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 
{
    HRESULT hr;
    LPWSTR strCombo = NULL;
    LPWSTR strEdit = NULL;
    
    DWORD dwSelectionIndex = (DWORD) ::SendMessage(m_hPropertyCategoryCombo, CB_GETCURSEL, 0, 0);
    if(dwSelectionIndex > m_arrCategoryIndex.GetCount())
    {
        dwSelectionIndex = 0;
    }
    m_dwChosenCategory = m_arrCategoryIndex.GetAt(dwSelectionIndex);
   
    int comboLength = ::GetWindowTextLength(m_hPropertyNameCombo);
    strCombo = new WCHAR[comboLength + 1];
    CHECK_ALLOC( strCombo );
    ::GetWindowText(m_hPropertyNameCombo, strCombo, comboLength + 1);
    m_strChosenProperty = CAtlStringW(strCombo);

    int editLength = ::GetWindowTextLength(m_hPropertyValueEdit);
    strEdit = new WCHAR[editLength + 1];
    CHECK_ALLOC( strEdit );
    ::GetWindowText(m_hPropertyValueEdit, strEdit, editLength + 1);
    m_strValue = CAtlStringW(strEdit);

Cleanup:
    delete[] strCombo;
    delete[] strEdit;

    EndDialog(IDOK);
    
    return 0;
}
Пример #2
0
CAtlStringW CFilePath::GetName() const
{
    if (GetLastChar(msPath) == '\\')
        return CAtlStringW();

    LPCTSTR psPath = msPath;
    LPCTSTR psFileName = PathFindFileName(psPath);
    if (psFileName == NULL)
        return CAtlStringW();

    return msPath.Mid(psFileName - psPath);
}
Пример #3
0
CNetRequestImpl::CNetRequestImpl(const char* method, const String& strUrl)
{
    pszErrFunction = NULL;
    hInet = NULL, hConnection = NULL, hRequest = NULL;
    memset(&uri, 0, sizeof(uri) );
    m_pInstance = this;

    CAtlStringW strUrlW(strUrl.c_str());

    do 
    {
        if ( !isLocalHost(strUrl.c_str()) && !SetupInternetConnection(strUrlW) )
        {
            pszErrFunction = L"SetupInternetConnection";
            break;
        }

        hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
        if ( !hInet ) 
        {
            pszErrFunction = L"InternetOpen";
            break;
        }

        DWORD dwUrlLength = 1024;
        CAtlStringW strCanonicalUrlW;
        if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
        {
            pszErrFunction = _T("InternetCanonicalizeUrl");
            break;
        }
        strCanonicalUrlW.ReleaseBuffer();

		alloc_url_components( &uri, strCanonicalUrlW );
        if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &uri ) ) 
        {
			pszErrFunction = L"InternetCrackUrl";
			break;
		}

        hConnection = InternetConnect( hInet, uri.lpszHostName, uri.nPort, _T("anonymous"), NULL, 
          INTERNET_SERVICE_HTTP, 0, 0 );
        if ( !hConnection ) 
        {
            pszErrFunction = L"InternetConnect";
            break;
        }

        strReqUrlW = uri.lpszUrlPath;
        strReqUrlW += uri.lpszExtraInfo;
        hRequest = HttpOpenRequest( hConnection, CAtlStringW(method), strReqUrlW, NULL, NULL, NULL, 
          INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE, NULL );
        if ( !hRequest ) 
        {
            pszErrFunction = L"HttpOpenRequest";
            break;
        }

    }while(0);
}
void CTedTransformDialog::PopulateCategory(DMOCategory& category) 
{
    TVINSERTSTRUCT treeInserter;
    treeInserter.hParent = TVI_ROOT;
    treeInserter.hInsertAfter = TVI_FIRST;

    CAtlString strName = LoadAtlString(category.m_nID);
    TVITEM item;
    item.mask = TVIF_TEXT;
    item.pszText = strName.GetBuffer();
    item.cchTextMax = strName.GetLength();

    treeInserter.item = item;
    HTREEITEM hBaseItem = (HTREEITEM) TreeView_InsertItem(m_hList, &treeInserter);

    assert(hBaseItem != NULL);

    treeInserter.hParent = hBaseItem;
    item.mask = TVIF_TEXT | TVIF_PARAM;

    DMO_PARTIAL_MEDIATYPE mediaType;
    CComPtr<IEnumDMO> spDMOList;

    mediaType.type = GUID_NULL;
    mediaType.subtype = GUID_NULL;
    
    IMFActivate** ppActivates = NULL;
    UINT32 cMFTs = 0;
    ::MFTEnumEx(category.m_GUID, MFT_ENUM_FLAG_ALL, NULL, NULL, &ppActivates, &cMFTs);

    for(DWORD i = 0; i < cMFTs; i++)
    {
        m_Activates.Add(ppActivates[i]);

        LPWSTR pszName = NULL;
        ppActivates[i]->GetAllocatedString(MFT_FRIENDLY_NAME_Attribute, &pszName, NULL);
        
        m_strNames.Add(CAtlStringW(pszName));
        item.pszText = m_strNames.GetAt(m_strNames.GetCount() - 1).GetBuffer();
        item.lParam = (LPARAM)  m_Activates.GetCount() - 1;

        treeInserter.item = item;

        TreeView_InsertItem(m_hList, &treeInserter);
        
        CoTaskMemFree(pszName);
    }

    CoTaskMemFree(ppActivates);
}
Пример #5
0
CIISxpressISAPIPerfObject* CIISxpressISAPIPerfObject::Create(LPCSTR pszInstanceName)
{
	CIISxpressISAPIPerfObject* pInstance = NULL;

	HRESULT hr = perfMon.Initialize();
	hr = perfMon.RegisterAllStrings();

	hr = perfMon.CreateInstanceByName(CIISxpressISAPIPerfObject::kCategoryId, CAtlStringW(pszInstanceName), (CPerfObject**) &pInstance);
	if (hr == S_OK && pInstance != NULL)
	{
		::InterlockedIncrement(&pInstance->instanceCount);
	}	

	return pInstance;
}
Пример #6
0
CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const String& strUrl, IRhoSession* oSession, Hashtable<String,String>* pHeaders)
{
    m_pParent = pParent;
    m_pParent->m_pCurNetRequestImpl = this;
    m_pHeaders = pHeaders;
    m_bCancel = false;
    m_pSession = oSession;

    pszErrFunction = NULL;
    hInet = NULL, hConnection = NULL, hRequest = NULL;
    memset(&uri, 0, sizeof(uri) );
    m_strUrl = strUrl;
    CAtlStringW strUrlW(strUrl.c_str());

    LOG(INFO) + "Method: " + method + ";Url: " + strUrl;
    do 
    {
        if ( !URI::isLocalHost(strUrl.c_str()) && !SetupInternetConnection(strUrlW) )
        {
            pszErrFunction = L"SetupInternetConnection";
            break;
        }

        hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
        if ( !hInet ) 
        {
            pszErrFunction = L"InternetOpen";
            break;
        }

        DWORD dwUrlLength = 1024;
        CAtlStringW strCanonicalUrlW;
        if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
        {
            pszErrFunction = _T("InternetCanonicalizeUrl");
            break;
        }
        strCanonicalUrlW.ReleaseBuffer();

		alloc_url_components( &uri, strCanonicalUrlW );
        if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &uri ) ) 
        {
			pszErrFunction = L"InternetCrackUrl";
			break;
		}

        hConnection = InternetConnect( hInet, uri.lpszHostName, uri.nPort, _T("anonymous"), NULL, 
          INTERNET_SERVICE_HTTP, 0, 0 );
        if ( !hConnection ) 
        {
            pszErrFunction = L"InternetConnect";
            break;
        }

        strReqUrlW = uri.lpszUrlPath;
        strReqUrlW += uri.lpszExtraInfo;
        DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_NO_COOKIES;
        if ( uri.lpszScheme && wcsicmp(uri.lpszScheme,L"https")==0)
            dwFlags |= INTERNET_FLAG_SECURE;

        hRequest = HttpOpenRequest( hConnection, CAtlStringW(method), strReqUrlW, NULL, NULL, NULL, dwFlags, NULL );
        if ( !hRequest ) 
        {
            pszErrFunction = L"HttpOpenRequest";
            break;
        }

        if (oSession!=null)
        {
			String strSession = oSession->getSession();
			LOG(INFO) + "Cookie : " + strSession;
			if ( strSession.length() > 0 )
            {
                String strHeader = "Cookie: " + strSession + "\r\n";

                if ( !HttpAddRequestHeaders( hRequest, common::convertToStringW(strHeader).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
                    pszErrFunction = L"HttpAddRequestHeaders";
            }
        }

    }while(0);
}