コード例 #1
0
// the icon will be downloaded to "my picture" folder in other OS or low security folder in VISTA
//	AddFavorite("Favorite Title", "http://www.groovedive.com", "http://mfiles.naver.net/9b4fac7b613b57e4c9b1/data33/2008/6/28/55/tulip-jangtimjang.ico");
BOOL CShortcutNBookmark::AddFavorite(const CString& FavoriteTitle, const CString& FavoriteUrl, const CString& csIconUrl)
{
	BOOL bRet = FALSE;
	CString csDownloadedFilePath;
	CString csFileName = csIconUrl.Right( csIconUrl.GetLength() - csIconUrl.ReverseFind('/') -1 );

	if ( m_bNoVista ) {
		// create file under window\\web\\wallpaper\\  
		CString csLocalFolderPath = ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "My Pictures");  
		//csLocalFolderPath = csLocalFolderPath.Left( csLocalFolderPath.ReverseFind('\\') );
		if ( csLocalFolderPath.GetLength() == 0 ) {
			csLocalFolderPath = "C:";
		}
		csLocalFolderPath.Replace( "%SystemRoot%", GetSpecialFolderLocation(CSIDL_WINDOWS));
		csDownloadedFilePath = csLocalFolderPath + "\\" + csFileName;
	}
	else {
		// if it's VISTA create file under c:\\users\\~~\\AppData\\LocalLow\\		 
		CString csLocalFolderPath = GetSpecialFolderLocation(CSIDL_PROFILE ) + "\\AppData\\localLow";
		csDownloadedFilePath = csLocalFolderPath + "\\" + csFileName;
	}

	if ( DownloadFile(csIconUrl, csDownloadedFilePath) ) 
	{
		bRet = CreateInternetShortcut(FavoriteTitle +".url" , 
			FavoriteUrl, 
			ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Favorites") ,
			csDownloadedFilePath
			);		
	}

	return bRet;
}
コード例 #2
0
ファイル: XMLDialog.cpp プロジェクト: jimmccurdy/ArchiveGit
// CXMLDialog message handlers
////////////////////////////////////////////////////////////////////////////
CString CXMLDialog::GetInitialDir()
{
#define CString ATL::CAtlString
	CString strDir;
	bool bOK = GetSpecialFolderLocation(strDir, CSIDL_COMMON_DESKTOPDIRECTORY);
	if (!bOK)
		bOK = GetSpecialFolderLocation(strDir, CSIDL_DESKTOPDIRECTORY);
#undef CString
	return strDir;
}
コード例 #3
0
bool CPhotoManager::AddAPhoto(IHTMLDocument2Ptr spDoc, CString& strFileName)
{
	CString strPath;
	bool bOK = GetSpecialFolderLocation(strPath, CSIDL_MYPICTURES);
	if (!bOK)
		 bOK = GetSpecialFolderLocation(strPath, CSIDL_COMMON_PICTURES);

	HWND hWndOwner = ::GetActiveWindow();
	if (spDoc)
	{
		CComQIPtr<IOleWindow> spOleWin = spDoc;
		if (spOleWin)
		{
			HWND hWnd = NULL;
			if (SUCCEEDED(spOleWin->GetWindow(&hWnd)))
				hWndOwner = hWnd;
		}
	}

	char szFileName[MAX_PATH];
	*szFileName = 0;

	struct OPENFILENAMEX
	{
		OPENFILENAME of;
		void* pvReserved;
		DWORD dwReserved;
		DWORD FlagsEx;
	};

	OPENFILENAMEX ofx;
	memset(&ofx, 0, sizeof(ofx));
	ofx.of.lStructSize = (IsEnhancedWinVersion() ? sizeof(ofx) : sizeof(ofx.of));
	ofx.of.hwndOwner = hWndOwner;
	ofx.of.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_ENABLEHOOK;
	ofx.of.lpstrFilter = "All Supported Files (*.bmp, *.gif, *.jpg, *.png, *.wmf, *.ico, *.emf)\0*.bmp;*.gif;*.jpg;*.png;*.wmf;*.ico;*.emf\0Bitmap Files (*.bmp)\0*.bmp\0GIF Files (*.gif)\0*.gif\0JPG Files (*.jpg)\0*.jpg\0PNG Files (*.png)\0*.png\0Windows Metafiles Files (*.wmf)\0*.wmf\0Windows Enhanced Metafiles Files (*.emf)\0*.emf\0Icon Files (*.ico)\0*.ico\0All Files (*.*)\0*.*\0\0";
	ofx.of.lpstrTitle = "Add a Photo® or an Art File";
	ofx.of.lpstrDefExt = "bmp";
	ofx.of.lpstrInitialDir = strPath;
	ofx.of.lpstrFile = szFileName;
	ofx.of.lpfnHook = NULL;
	ofx.of.nMaxFile = MAX_PATH;

	m_hWndOpenDialog = hWndOwner;
	bOK = !!::GetOpenFileName(&ofx.of);
	m_hWndOpenDialog = NULL;

	if (bOK)
		strFileName = szFileName;
	return bOK;
}
コード例 #4
0
HRESULT CVBoxMachine::Exec(const wchar_t* pszCommandLine, DWORD* ppid, HANDLE* phProcess)
{
	// Get from the InstallDir registry key
	CUniString strVBoxPath;
	RegGetString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Oracle\\VirtualBox", L"InstallDir", strVBoxPath);

	// If that fails, assume program files...
	if (strVBoxPath.IsEmpty())
	{
		// Work out path to vbox
		GetSpecialFolderLocation(CSIDL_PROGRAM_FILES, L"Oracle\\VirtualBox", false, strVBoxPath);
	}

	// Remove trailing backslash
	RemoveTrailingBackslash(strVBoxPath.GetBuffer());

	CUniString str=StringReplace(pszCommandLine, L"{vboxdir}", strVBoxPath, true);
	str=StringReplace(str, L"{machinename}", m_strMachineName, true);

	// Setup startup info
	STARTUPINFO si;
	memset(&si, 0, sizeof(si));
	si.cb=sizeof(si);

	// Setup process info
	PROCESS_INFORMATION pi;
	memset(&pi, 0, sizeof(pi));

	// Create the process
	if (!CreateProcess(NULL, str.GetBuffer(), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
	{
		return HRESULT_FROM_WIN32(GetLastError());
	}


	// Close/return handles
	if (phProcess)
	{
		phProcess[0]=pi.hProcess;
	}
	else
	{
		CloseHandle(pi.hProcess);
	}
	CloseHandle(pi.hThread);

	// Return the process ID
	if (ppid)
	{
		ppid[0]=pi.dwProcessId;
	}

	return S_OK;
}
コード例 #5
0
ファイル: TrueType.cpp プロジェクト: jimmccurdy/ArchiveGit
CString CTrueType::GetPathFromFileName(LPCTSTR pszFileName)
{
	// Compute the font file location
#define CString ATL::CAtlString
	CString strPath;
	GetSpecialFolderLocation(strPath, CSIDL_FONTS);
#undef CString
	strPath += '\\';
	strPath += pszFileName;
	return strPath;
}