Exemple #1
0
void CProfilesDlg::OnRenameProfile() 
{
    CRenameProfileDlg dialog;

    int itemIndex = m_ProfileList.GetCurSel();
    ASSERT(itemIndex != LB_ERR);
    if (itemIndex == LB_ERR)
        return;

    m_ProfileList.GetText(itemIndex, dialog.m_CurrentName);

    if (dialog.DoModal() == IDOK)
    {
        USES_CONVERSION;

        nsresult rv;

        nsCOMPtr<nsIProfile> profileService = 
                 do_GetService(NS_PROFILE_CONTRACTID, &rv);
        ASSERT(NS_SUCCEEDED(rv));
        if (NS_SUCCEEDED(rv))
        {
            rv = profileService->RenameProfile(T2CW(dialog.m_CurrentName), T2CW(dialog.m_NewName));
            ASSERT(NS_SUCCEEDED(rv));
        }
    }    
}
Exemple #2
0
void CButtonDialog::FillInHeader(LPDLGTEMPLATE lpDlgTmp)
{
	USES_CONVERSION;
	lpDlgTmp->style = DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE |
		WS_CAPTION | WS_SYSMENU;
	if (theApp.m_bWin4)
		lpDlgTmp->style |= DS_CONTEXTHELP;
	lpDlgTmp->dwExtendedStyle = 0;
	lpDlgTmp->cdit = 0;
	lpDlgTmp->x = 0;
	lpDlgTmp->y = 0;
	lpDlgTmp->cx = 100;
	lpDlgTmp->cy = 100;

	LPWSTR lpStr = (LPWSTR)(lpDlgTmp + 1); /* Move ptr to the variable fields */

	*lpStr++ = 0;  /* No Menu resource for Message Box */
	*lpStr++ = 0;  /* No Class name for MessageBox */

	int nLen = m_strCaption.GetLength();
	wcscpy(lpStr, T2CW(m_strCaption));

	lpStr += nLen+1;
	WORD* pWord = (WORD*)lpStr;
	*pWord = 10; // 10 pt font
	pWord++;
	lpStr = (LPWSTR) pWord;

	wcscpy(lpStr, T2W(theApp.m_lf.lfFaceName));
}
STDMETHODIMP CBmpCtxMenuExt::GetCommandString (
                               UINT uCmd, UINT uFlags, UINT* puReserved,
                               LPSTR pszName, UINT cchMax )
{
static LPCTSTR szHelpString = _T("Click the thumbnail to view the entire picture.");

    USES_CONVERSION;

    // Check idCmd, it must be 0 since we have only one menu item.
    if ( 0 != uCmd )
        return E_INVALIDARG;

    // If Explorer is asking for a help string, copy our string into the
    // supplied buffer.
    if ( uFlags & GCS_HELPTEXT )
        {
        if ( uFlags & GCS_UNICODE )
            {
            // We need to cast pszName to a Unicode string, and then use the
            // Unicode string copy API.
            lstrcpynW ( (LPWSTR) pszName, T2CW(szHelpString), cchMax );
            }
        else
            {
            // Use the ANSI string copy API to return the help string.
            lstrcpynA ( pszName, T2CA(szHelpString), cchMax );
            }
        }

    return S_OK;
}
	STDMETHODIMP CDuiAutoComplete::Next(ULONG celt, LPOLESTR* rgelt, ULONG* pceltFetched)
	{
		USES_CONVERSION;
		HRESULT hr = S_FALSE;

		if (!celt)
			celt = 1;
		ULONG i;
		for (i = 0; i < celt; i++)
		{
			if (m_nCurrentElement == (ULONG)m_sStringArrayMap.GetSize())
				break;

			rgelt[i] = (LPWSTR)::CoTaskMemAlloc((ULONG) sizeof(WCHAR) * (m_sStringArrayMap.GetAt(m_nCurrentElement)->GetLength() + 1));
			wcscpy(rgelt[i], T2CW(m_sStringArrayMap.GetAt(m_nCurrentElement)->GetData()));

			if (pceltFetched)
				*pceltFetched++;

			m_nCurrentElement++;
		}

		if (i == celt)
			hr = S_OK;

		return hr;
	}
Exemple #5
0
HRESULT TCUserAccount::HasRight(LPTSTR pszPrivilege) const
{
  // Not supported under Windows9x
  if (IsWin9x())
    return S_FALSE;

  // Fail if Init has not been called successfully
  if (!m_hPolicy || m_spSIDPrincipal.IsNull())
    return E_UNEXPECTED;

  // Fail if the specified pointer is NULL
  if (!pszPrivilege)
    return E_POINTER;

  // Get the array of user rights
  PLSA_UNICODE_STRING pUserRights = NULL;
  ULONG cRights = 0;
  RETURN_FAILED(LsaEnumerateAccountRights(m_hPolicy, m_spSIDPrincipal,
    &pUserRights, &cRights));

  // Get a pointer to a UNICODE version of the specified privilege
  USES_CONVERSION;
  LPCWSTR pszWidePrivilege = T2CW(pszPrivilege);

  // Loop through the array of privileges
  for (ULONG i = 0; i < cRights; ++i)
    if (0 == _wcsicmp(pUserRights[i].Buffer, pszWidePrivilege))
      return S_OK;

  // Specified privilege wasnt' found
  return S_FALSE;
}
Exemple #6
0
void CFolderDialog::SetOKText( IN LPCTSTR pszText )
{
	USES_CONVERSION;
	ASSERT( m_hWnd != NULL );	
	
	::SendMessage( m_hWnd, BFFM_SETOKTEXT, (WPARAM)0, (LPARAM)T2CW( pszText ) );
}
STDMETHODIMP CSimpleShlExt::GetCommandString (
    UINT_PTR idCmd, UINT uFlags, UINT* pwReserved, LPSTR pszName, UINT cchMax )
{
USES_CONVERSION;

    // Check idCmd, it must be 0 since we have only one menu item.
    if ( 0 != idCmd )
        return E_INVALIDARG;

    // If Explorer is asking for a help string, copy our string into the
    // supplied buffer.
    if ( uFlags & GCS_HELPTEXT )
        {
        LPCTSTR szText = _T("Git shell extensions");

        if ( uFlags & GCS_UNICODE )
            {
            // We need to cast pszName to a Unicode string, and then use the
            // Unicode string copy API.
            lstrcpynW ( (LPWSTR) pszName, T2CW(szText), cchMax );
            }
        else
            {
            // Use the ANSI string copy API to return the help string.
            lstrcpynA ( pszName, T2CA(szText), cchMax );	
            }

        return S_OK;
        }

    return E_INVALIDARG;
}
STDMETHODIMP CCustomAutoComplete::Next(ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched)
{
	USES_CONVERSION;

	HRESULT	hr = S_FALSE;
	ULONG	ui;

	if (celt == 0)
		celt = 1;

	for (ui = 0; ui < celt; ui++)
	{
		if (m_uiCurrentElement == static_cast<ULONG>(m_asList.GetSize()))
			break;

		rgelt[ui] = (LPWSTR)::CoTaskMemAlloc((ULONG) sizeof(WCHAR) * (m_asList[m_uiCurrentElement].GetLength() + 1));
		wcscpy(rgelt[ui], T2CW(m_asList[m_uiCurrentElement]));

		if (pceltFetched != NULL)
			*pceltFetched++;

		m_uiCurrentElement++;
	}

	if (ui == celt)
		hr = S_OK;

	return hr;
}
Exemple #9
0
// Static Routines
static void ValidateProfileName(const CString& profileName, CDataExchange* pDX)
{
    USES_CONVERSION;

    nsresult rv;
    PRBool exists = FALSE;

    {
        nsCOMPtr<nsIProfile> profileService = 
                 do_GetService(NS_PROFILE_CONTRACTID, &rv);
        rv = profileService->ProfileExists(T2CW(profileName), &exists);
    }

    if (NS_SUCCEEDED(rv) && exists)
    {
        CString errMsg;
        errMsg.Format(_T("Error: A profile named \"%s\" already exists."), profileName);
        AfxMessageBox( errMsg, MB_ICONEXCLAMATION );
        errMsg.Empty();
        pDX->Fail();
    }

    if (profileName.FindOneOf(_T("\\/")) != -1)
    {
        AfxMessageBox( _T("Error: A profile name cannot contain the characters \"\\\" or \"/\"."), MB_ICONEXCLAMATION );
        pDX->Fail();
    }
}
	BOOL CDuiAutoComplete::Bind(HWND p_hWndEdit, DWORD p_dwOptions, LPCTSTR p_lpszFormatString)
	{
		ATLASSERT(::IsWindow(p_hWndEdit));
		if ((m_fBound) || (GetIAutoComplete()))
			return FALSE;

		HRESULT hr = GetIAutoComplete().CoCreateInstance(CLSID_AutoComplete);
		if (SUCCEEDED(hr))
		{
			if (p_dwOptions){
				CComQIPtr<IAutoComplete2> pAC2(GetIAutoComplete());
				if (pAC2){
					pAC2->SetOptions(p_dwOptions);
					pAC2.Release();
				}
			}

			USES_CONVERSION;
			if (SUCCEEDED(hr = GetIAutoComplete()->Init(p_hWndEdit, this, NULL, T2CW(p_lpszFormatString))))
			{
				m_fBound = TRUE;
				return TRUE;
			}
		}
		return FALSE;
	}
HRESULT CSimpleShlExt::GetCommandString( UINT idCmd, UINT uFlags,UINT* pwReserved, LPSTR pszName, UINT cchMax ) 
{
	USES_CONVERSION; 
	//检查 idCmd, 它必须是0,因为我们仅有一个添加的菜单项. 
	if ( 0 != idCmd ) 
		return E_INVALIDARG; 

	// 如果 Explorer 要求帮助字符串,就将它拷贝到提供的缓冲区中. 
	if ( uFlags & GCS_HELPTEXT ) 
	{
		LPCTSTR szText = _T("This is the simple shell extension's help");              
		if ( uFlags & GCS_UNICODE )
		{ 
			// 我们需要将 pszName 转化为一个 Unicode 字符串, 接着使用Unicode字符串拷贝 API. 
			lstrcpynW ( (LPWSTR) pszName, T2CW(szText), cchMax ); 
		} 
		else
		{ 
			// 使用 ANSI 字符串拷贝API 来返回帮助字符串. 
			lstrcpynA ( pszName, T2CA(szText), cchMax ); 
		} 
		return S_OK;
	} 
	return E_INVALIDARG; 
}
Exemple #12
0
void CProfilesDlg::OnDeleteProfile() 
{
    int itemIndex = m_ProfileList.GetCurSel();
    ASSERT(itemIndex != LB_ERR);
    if (itemIndex == LB_ERR)
        return;

    CString selectedProfile;
    m_ProfileList.GetText(itemIndex, selectedProfile);
    
    nsresult rv;
    nsCOMPtr<nsIProfile> profileService = 
             do_GetService(NS_PROFILE_CONTRACTID, &rv);
    ASSERT(NS_SUCCEEDED(rv));
    if (NS_SUCCEEDED(rv))
    {
        USES_CONVERSION;

        rv = profileService->DeleteProfile(T2CW(selectedProfile), PR_TRUE);
        ASSERT(NS_SUCCEEDED(rv));
        if (NS_SUCCEEDED(rv))
        {
            int itemCount = m_ProfileList.DeleteString(itemIndex);
            if (itemCount == 0)
                GetDlgItem(IDOK)->EnableWindow(FALSE);
        }
    }    
}
Exemple #13
0
void CProfilesDlg::OnNewProfile() 
{
    CNewProfileDlg dialog;

    if (dialog.DoModal() == IDOK)
    {
        nsresult rv;

        nsCOMPtr<nsIProfile> profileService = 
                 do_GetService(NS_PROFILE_CONTRACTID, &rv);
        ASSERT(NS_SUCCEEDED(rv));
        if (NS_SUCCEEDED(rv))
        {
            USES_CONVERSION;

            rv = profileService->CreateNewProfile(T2CW(dialog.m_Name), nsnull, nsnull, PR_FALSE);
            ASSERT(NS_SUCCEEDED(rv));
            if (NS_SUCCEEDED(rv))
            {
                int item = m_ProfileList.AddString(dialog.m_Name);
                m_ProfileList.SetCurSel(item);
                GetDlgItem(IDOK)->EnableWindow(TRUE);
            }
        }
    }
}
Exemple #14
0
void CWGUrlReceiver::CheckRapidshare()
{
	USES_CONVERSION;
	extern LPCTSTR strcmpi_m (LPCTSTR pszWhere, LPCTSTR pszWhat);
	fsURL url;
	if (IR_SUCCESS != url.Crack (W2CT (m_dlInfo.bstrUrl)))
		return;
	if (_tcsicmp (url.GetHostName (), _T("rapidshare.com")) == 0 ||
			strcmpi_m (url.GetHostName (), _T("*.rapidshare.com")) == 0)
	{
		tstring strPath = url.GetPath ();
		LPCTSTR psz = _tcsrchr (strPath.c_str (), _T('#'));
		if (psz)
		{
			strPath.erase (strPath.begin () + (psz-strPath.c_str ()), strPath.end ());
			fsURL url2;
			TCHAR szUrl [10000] = _T("");
			DWORD dwSize = _countof (szUrl);
			if (IR_SUCCESS == url2.Create (url.GetInternetScheme (), url.GetHostName (), url.GetPort (), 
					url.GetUserName (), url.GetPassword (), strPath.c_str (), szUrl, &dwSize))
			{
				m_dlInfo.bstrUrl = T2CW (szUrl);
			}
		}
	}
}
Exemple #15
0
STDMETHODIMP ExifShellExtension::GetCommandString(
   UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax)
{
   // If Explorer is asking for a help string, copy our string into the
   // supplied buffer.
   if (uFlags & GCS_HELPTEXT)
   {
      CString cszText;
      if (idCmd == m_uidMenuCopyExif)
         cszText = _T("Copies Exif data to clipboard");
      else if (idCmd == m_uidMenuPasteExif)
         cszText = _T("Pastes Exif data from clipboard");
      else
         return E_INVALIDARG;

      USES_CONVERSION;
      if (uFlags & GCS_UNICODE)
      {
         // We need to cast pszName to a Unicode string, and then use the
         // Unicode string copy API.
         lstrcpynW(reinterpret_cast<LPWSTR>(pszName), T2CW(cszText), cchMax);
      }
      else
      {
         // Use the ANSI string copy API to return the help string.
         lstrcpynA(pszName, T2CA(cszText), cchMax);
      }

      return S_OK;
   }

   return E_INVALIDARG;
}
Exemple #16
0
HRESULT CSimpleShlExt::GetCommandString( UINT  idCmd,      UINT uFlags,
										 UINT* pwReserved, LPSTR pszName,
										 UINT  cchMax )
{
	USES_CONVERSION;

	// Check idCmd, it must be 0 since we have only one menu item.
	if (idCmd != 0)
		return E_INVALIDARG;

	// If Explorer is asking for a help string, copy our string into the
	// supplied buffer.
	if (uFlags & GCS_HELPTEXT)
	{
		TCHAR szBuffer[256];
		::LoadString(NULL, IDS_COMMAND_STRING, szBuffer, sizeof(szBuffer)/sizeof(szBuffer[0]));

		if (uFlags & GCS_UNICODE)
			// We need to cast pszName to a Unicode string, and then use the
			// Unicode string copy API.
			lstrcpynW( (LPWSTR) pszName, T2CW(szBuffer), cchMax );
		else
			// Use the ANSI string copy API to return the help string.
			lstrcpynA( pszName, T2CA(szBuffer), cchMax );

		return S_OK;
	}

	return E_INVALIDARG;
}
Exemple #17
0
HRESULT CMainFrameDropTarget::AddUrlFileContents(LPCTSTR pszFileName)
{
	HRESULT hrResult = S_FALSE;

	TCHAR szExt[_MAX_EXT];
	_tsplitpath(pszFileName, NULL, NULL, NULL, szExt);
	if (_tcsicmp(szExt, FILEEXTDOT_INETSHRTCUT) == 0)
	{
		CComPtr<IUniformResourceLocatorW> pIUrl;
		if (SUCCEEDED(hrResult = CoCreateInstance(CLSID_InternetShortcut, NULL, CLSCTX_INPROC_SERVER, IID_IUniformResourceLocatorW, (void**)&pIUrl)))
		{
			CComPtr<IPersistFile> pIFile;
			if (SUCCEEDED(hrResult = pIUrl.QueryInterface(&pIFile)))
			{
				USES_CONVERSION;
				if (SUCCEEDED(hrResult = pIFile->Load(CComBSTR(T2CW(pszFileName)), STGM_READ | STGM_SHARE_DENY_WRITE)))
				{
					LPWSTR pwszUrl;
					if ((hrResult = pIUrl->GetURL(&pwszUrl)) == S_OK)
					{
						if (pwszUrl != NULL && pwszUrl[0] != L'\0' && IsUrlSchemeSupportedW(pwszUrl))
						{
							theApp.emuledlg->ProcessED2KLink(W2T(pwszUrl));
							hrResult = S_OK;
						}
						::CoTaskMemFree(pwszUrl);
					}
				}
			}
		}
	}

	return hrResult;
}
Exemple #18
0
	void OnOK(HWND hWnd)
	{
		winx::SaveFileDialog dlg(
			_T("TIFF files(*.tif;*.tiff)\0*.tif;*.tiff\0"), _T("*.tif"));
		
		if (IDOK != dlg.DoModal())
			return;
		
		TCHAR szFrame[] = _T("Frame1");

		USES_CONVERSION;
		CLSID clsid;
		Gdiplus::GetEncoderClsid(L"image/tiff", &clsid);
		Gdiplus::MultiFrameImageCreator multi(T2CW(dlg.lpstrFile), clsid);
		
		for (UINT i = 1; i < 10; ++i)
		{
			szFrame[5] = '0' + i;
			::SetDlgItemText(hWnd, IDC_PROMPT, szFrame);
			
			HBITMAP hbm = winx::ScreenCapture(hWnd);
			{
				Gdiplus::Bitmap bitmap(hbm, NULL);
				WINX_ASSERT(bitmap.GetLastStatus() == Gdiplus::Ok);
				multi.Add(bitmap);
			}
			::DeleteObject(hbm);
		}
		CloseDialog(hWnd);
	}
Exemple #19
0
void CFolderDialog::SetExpanded( IN LPCTSTR pszPath )
{
	USES_CONVERSION;

	ASSERT( m_hWnd != NULL );
	ASSERT( AfxIsValidString( pszPath, MAX_PATH ) );
	
	::SendMessage( m_hWnd, BFFM_SETEXPANDED, (WPARAM)TRUE, (LPARAM)T2CW( pszPath ) );
}
Exemple #20
0
CArchive& AFXAPI operator<<(CArchive& ar, const CString& string)
{
	USES_CONVERSION;

	// All CStrings are serialized as wide strings
	PCWSTR pWide = T2CW(string.data());
	int nChars = wcslen(pWide);
	ar << nChars;
	ar.Write(pWide, nChars*sizeof(wchar_t));
	return ar;
}
Exemple #21
0
bool CTextToSpeech::Speak(LPCTSTR pwsz)
{
	bool bResult = false;
	USES_CONVERSION;
	if (m_pISpVoice)
	{
		if (SUCCEEDED(m_pISpVoice->Speak(T2CW(pwsz), SPF_ASYNC | SPF_IS_NOT_XML, NULL)))
			bResult = true;
	}
	return bResult;
}
eResult CSecRunAsUser::RestartAsUser(){
	USES_CONVERSION;

	if (m_bRunningRestricted || m_bRunningAsEmule)
		return RES_OK;
	if (!LoadAPI())
		return RES_FAILED;

	ASSERT ( !m_strPassword.IsEmpty() );
	BOOL bResult;
	try{
		PROCESS_INFORMATION ProcessInfo = {0};
		TCHAR szAppPath[MAX_PATH];
		GetModuleFileName(NULL, szAppPath, MAX_PATH);
		CString strAppName;
		strAppName.Format(_T("\"%s\""),szAppPath);
		
		STARTUPINFOW StartInf = {0};
		StartInf.cb = sizeof(StartInf);
		StartInf.dwFlags = STARTF_USESHOWWINDOW;
		StartInf.wShowWindow = SW_NORMAL;

		// remove the current mutex, so that the restart emule can create its own without problems
		// in the rare case CreateProcessWithLogonW fails, this will allow mult. instances, but if that function fails we have other problems anyway
		//MODIFIED by fengwen on 2007/03/05	<begin> :
		//::CloseHandle(theApp.m_hMutexOneInstance);
		if (NULL != theApp.m_pSingleInst)
			theApp.m_pSingleInst->AppEnd();
		//MODIFIED by fengwen on 2007/03/05	<end> :
		if (NULL != theApp.m_pSingleInst2Loader)
			theApp.m_pSingleInst2Loader->AppEnd();
		
		bResult = CreateProcessWithLogonW(EMULEACCOUNTW, m_strDomain, m_strPassword,
			LOGON_WITH_PROFILE, NULL, (LPWSTR)T2CW(strAppName), 0, NULL, NULL, &StartInf, &ProcessInfo);
		CloseHandle(ProcessInfo.hProcess);
		CloseHandle(ProcessInfo.hThread);

	}
	catch(...){
		CGlobalVariable::QueueDebugLogLine(false, _T("Run as unpriveleged user: Error: Unexpected exception while loading advapi32.dll"));
		FreeAPI();
		return RES_FAILED;
	}
	FreeAPI();
	if (!bResult)
		CGlobalVariable::QueueDebugLogLine(false, _T("Run as unpriveleged user: Error: Failed to restart eMule as different user! Error Code: %i"),GetLastError());
	
	if (bResult)
		return RES_OK_NEED_RESTART;
	else
		return RES_FAILED;
}
Exemple #23
0
short COledbRecordset::GetColumnIndex(LPCTSTR pstrName) const
{
   _ASSERTE(IsOpen());
   _ASSERTE(!::IsBadStringPtr(pstrName,(UINT)-1));
   USES_CONVERSION;
   LPCWSTR pwstrName = T2CW(pstrName);
   LPCWSTR pwstr = m_pwstrNameBuffer;
   if( pwstr == NULL ) return FALSE;
   for( short i = 0; i < m_nCols; i++ ) {
      if( ::lstrcmpiW(pwstrName, pwstr) == 0 ) return i - m_iAdjustIndex;;
      pwstr += ::lstrlenW(pwstr) + 1;
   }
   return -1;
}
Exemple #24
0
HRESULT BitmapUtil::SaveBitmap(HBITMAP hBitmap, LPCTSTR pszFileName)
{
	ULONG_PTR dwToken = 0;

	Gdiplus::GdiplusStartupInput input;
	Gdiplus::GdiplusStartupOutput output;
	Gdiplus::Status status = Gdiplus::GdiplusStartup( &dwToken, &input, &output );
	if( status != Gdiplus::Ok )
	{
		return E_FAIL;
	}

	{
		USES_CONVERSION;
		UINT nEncoders;
		UINT nBytes;

		status = Gdiplus::GetImageEncodersSize( &nEncoders, &nBytes );
		if( status != Gdiplus::Ok )
		{
			return E_FAIL;
		}

		Gdiplus::ImageCodecInfo* pEncoders = static_cast< Gdiplus::ImageCodecInfo* >( _alloca( nBytes ) );
		status = Gdiplus::GetImageEncoders( nEncoders, nBytes, pEncoders );
		if( status != Gdiplus::Ok )
		{
			return E_FAIL;
		}

		CLSID clsidEncoder = CLSID_NULL;
		// Determine clsid from extension
		clsidEncoder = FindCodecForExtension( ::PathFindExtension( pszFileName ), pEncoders, nEncoders );

		if( clsidEncoder == CLSID_NULL )
		{
			return E_FAIL;
		}

		Gdiplus::Bitmap bm( hBitmap, NULL );
		status = bm.Save( T2CW( pszFileName ), &clsidEncoder, NULL );
		if( status != Gdiplus::Ok )
		{
			return E_FAIL;
		}
	}
	Gdiplus::GdiplusShutdown( dwToken );
	return S_OK;
}
LRESULT CChildFrame::OnFileDelNode(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	USES_CONVERSION;

	wNotifyCode, wID, hWndCtl, bHandled;
	HRESULT hr = E_FAIL;
	ATLTRACE(_T("CChildFrame::OnFileDelNode\r\n"));

	TREE_ITEM_DATA * pTmp = NULL;
	TREE_ITEM_DATA * pParent = NULL;
	LPBYTE pFileData = NULL;
	HANDLE hFile = NULL;
	
	do 
	{
		pTmp = (TREE_ITEM_DATA *)m_pData.GetData(); 
		
		if (NULL == pTmp) { break; }

		pParent = (TREE_ITEM_DATA *) m_pData.GetParent().GetData();
		if (NULL == pParent) {
			AtlMessageBox(*this, IDS_DEL_NODE, IDS_WARNING);
			break;
		}

		if (IDOK != AtlMessageBox(*this, IDS_CONFORM, IDS_WARNING, MB_OKCANCEL))
		{ break; }

		ATLASSERT(pParent->dwStgType == STGTY_STORAGE);

		CComPtr<IStorage> spParent;
		hr = pParent->spStgOrStrm->QueryInterface(&spParent);
		if (FAILED(hr)) { break; }

		TCHAR szName[MAX_PATH] = { 0 };
		m_pData.GetText(szName, _countof(szName));
		hr = spParent->DestroyElement( T2CW(szName) );
		if (FAILED(hr)) { break; }

		m_wndCatalog.DeleteItem(m_pData.m_hTreeItem);
	} while (FALSE);
	return 0;
}
Exemple #26
0
	void OnCmdFileOpen(HWND hWnd)
	{
		winx::OpenFileDialog dlg(
			_T("Images Files(*.jpg;*.png;*.tif;*.bmp;*.gif)\0*.jpg;*.png;*.tif;*.bmp;*.gif\0All Files(*.*)\0*.*\0")
			);
		if (IDOK == dlg.DoModal())
		{
 			USES_CONVERSION;
 			Gdiplus::Image* image = new Gdiplus::Image(T2CW(dlg.lpstrFile));
 			if (image->GetLastStatus() != Gdiplus::Ok)
			{
				delete image;
				winx::ExMsgBoxTrace(hWnd, _T("Error"), _T("Can't load image from %s"), dlg.lpstrFile);
 			}
 			else
 			{
 				SetImage(image);
 			}
		}
	}
Exemple #27
0
void CWGUrlReceiver::CheckYouTubePicture(){
	if (m_dlInfo.bstrUrl.Length() == 0)
		return;

	fsURL url;
	if (IR_SUCCESS != url.Crack(W2CT(m_dlInfo.bstrUrl)))
		return;

	std::wstring sUrl(m_dlInfo.bstrUrl);
	auto youTubeParserDllMgr = vmsYouTubeParserDllMgr::get();
	if (!youTubeParserDllMgr)
	{
		return;
	}
	auto extractor = youTubeParserDllMgr->objectsHolder()->createResourceObject(L"");
	std::wstring youTubeID;
	if (extractor && extractor->object()->extractIDFromImageURL(sUrl, youTubeID)){
		std::wstring youTubeDownloadURL = extractor->object()->createDownloadURLFromID(youTubeID);
		m_dlInfo.bstrUrl = T2CW(youTubeDownloadURL.c_str());
	}
}
Exemple #28
0
BOOL COledbDatabase::ExecuteSQL(LPCTSTR pstrSQL, long lType /*= DB_OPEN_TYPE_FORWARD_ONLY*/, long lOptions /*= DB_OPTION_DEFAULT*/, DWORD* pdwRowsAffected/*= NULL*/)
{
   USES_CONVERSION;
   HRESULT Hr;

   if( pdwRowsAffected ) *pdwRowsAffected = 0;
   CComQIPtr<IDBCreateCommand> spCreate = m_spSession;
   if( spCreate == NULL ) return FALSE;
   CComPtr<ICommand> spCommand;
   Hr = spCreate->CreateCommand(NULL, IID_ICommand, (LPUNKNOWN*) &spCommand);
   if( FAILED(Hr) ) return _Error(Hr);
   _SetRecordsetType(spCommand, lType, lOptions);
   CComQIPtr<ICommandText> spText = spCommand;
   _ASSERTE(spText);
   Hr = spText->SetCommandText(DBGUID_DBSQL, T2CW(pstrSQL));
   if( FAILED(Hr) ) return _Error(Hr);
   CComPtr<IRowset> spRowset;
   Hr = spText->Execute(NULL, IID_IRowset, NULL, (LONG*) pdwRowsAffected, (LPUNKNOWN*) &spRowset);
   if( FAILED(Hr) ) return _Error(Hr);
   return TRUE;
}
Exemple #29
0
void CProfilesDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CProfilesDlg)
    DDX_Control(pDX, IDC_LIST1, m_ProfileList);
    DDX_Check(pDX, IDC_CHECK_ASK_AT_START, m_bAskAtStartUp);
    //}}AFX_DATA_MAP

    if (pDX->m_bSaveAndValidate)
    {
        USES_CONVERSION;

        int itemIndex = m_ProfileList.GetCurSel();
        if (itemIndex != LB_ERR)
        {
            CString itemText;
            m_ProfileList.GetText(itemIndex, itemText);
            m_SelectedProfile.Assign(T2CW(itemText));
        }
    }
}
Exemple #30
-1
HRESULT TCUserAccount::SetRunAsInteractiveUser(LPCTSTR szAppID)
{
  // Not supported under Windows9x
  if (IsWin9x())
    return S_FALSE;

  // Copy the specified AppID string to a non-const wide string
  USES_CONVERSION;
  UINT cchAppID = max(_tcslen(szAppID), 48) + 1;
  LPWSTR pszAppID = (LPWSTR)_alloca(cchAppID * sizeof(WCHAR));
  wcscpy(pszAppID, T2CW(szAppID));

  // Resolve the specified string to an AppID
  HKEY hkey = NULL;
  RETURN_FAILED(ResolveAppID(pszAppID, &hkey));
  CRegKey key;
  key.Attach(hkey);

  // Set "Interactive User" as the RunAs user for the AppID
  // mdvalley: it used to be SetStringValue, but that ain't in my ATL.
  LONG lr = key.SetValue(TEXT("RunAs"), TEXT("Interactive User"));
  if (lr)
    return HRESULT_FROM_WIN32(lr);

  // Indicate success
  return S_OK;
}