Esempio n. 1
0
BOOL ShellEntry::launch_entry(HWND hwnd, UINT nCmdShow)
{
	CONTEXT("ShellEntry::launch_entry()");

	SHELLEXECUTEINFO shexinfo;

	shexinfo.cbSize = sizeof(SHELLEXECUTEINFO);
	shexinfo.fMask = SEE_MASK_INVOKEIDLIST;	// SEE_MASK_IDLIST is also possible.
	shexinfo.hwnd = hwnd;
	shexinfo.lpVerb = NULL;
	shexinfo.lpFile = NULL;
	shexinfo.lpParameters = NULL;
	shexinfo.lpDirectory = NULL;
	shexinfo.nShow = nCmdShow;

	ShellPath shell_path = create_absolute_pidl();
	shexinfo.lpIDList = &*shell_path;

	 // add PIDL to the recent file list
	SHAddToRecentDocs(SHARD_PIDL, shexinfo.lpIDList);

	BOOL ret = TRUE;

	if (!ShellExecuteEx(&shexinfo)) {
		display_error(hwnd, GetLastError());
		ret = FALSE;
	}

	return ret;
}
void GHOST_SystemPathsWin32::addToSystemRecentFiles(const char *filename) const
{
	/* SHARD_PATH resolves to SHARD_PATHA for non-UNICODE build */
	UTF16_ENCODE(filename);
	SHAddToRecentDocs(SHARD_PATHW, filename_16);
	UTF16_UN_ENCODE(filename);
}
Esempio n. 3
0
void RecentsMRL::addRecent( const QString &mrl )
{
    if ( !isActive || ( filter && filter->indexIn( mrl ) >= 0 ) )
        return;

    msg_Dbg( p_intf, "Adding a new MRL to recent ones: %s", qtu( mrl ) );

#ifdef _WIN32
    /* Add to the Windows 7 default list in taskbar */
    char* path = make_path( qtu( mrl ) );
    if( path )
    {
        wchar_t *wmrl = ToWide( path );
        SHAddToRecentDocs( SHARD_PATHW, wmrl );
        free( wmrl );
        free( path );
    }
#endif

    int i_index = stack->indexOf( mrl );
    if( 0 <= i_index )
    {
        /* move to the front */
        stack->move( i_index, 0 );
    }
    else
    {
        stack->prepend( mrl );
        if( stack->count() > RECENTS_LIST_SIZE )
            stack->takeLast();
    }
    VLCMenuBar::updateRecents( p_intf );
    save();
}
Esempio n. 4
0
void Win32TaskbarManager::addRecent(const Common::String &name, const Common::String &description) {
	//warning("[Win32TaskbarManager::addRecent] Adding recent list entry: %s (%s)", name.c_str(), description.c_str());

	if (_taskbar == NULL)
		return;

	// ANSI version doesn't seem to work correctly with Win7 jump lists, so explicitly use Unicode interface.
	IShellLinkW *link;

	// Get the ScummVM executable path.
	WCHAR path[MAX_PATH];
	GetModuleFileNameW(NULL, path, MAX_PATH);

	// Create a shell link.
	if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast<void **> (&link)))) {
		// Convert game name and description to Unicode.
		LPWSTR game = ansiToUnicode(name.c_str());
		LPWSTR desc = ansiToUnicode(description.c_str());

		// Set link properties.
		link->SetPath(path);
		link->SetArguments(game);

		Common::String iconPath = getIconPath(name);
		if (iconPath.empty()) {
			link->SetIconLocation(path, 0); // No game-specific icon available
		} else {
			LPWSTR icon = ansiToUnicode(iconPath.c_str());

			link->SetIconLocation(icon, 0);

			delete[] icon;
		}

		// The link's display name must be set via property store.
		IPropertyStore* propStore;
		HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast<void **> (&(propStore)));
		if (SUCCEEDED(hr)) {
			PROPVARIANT pv;
			pv.vt = VT_LPWSTR;
			pv.pwszVal = desc;

			hr = propStore->SetValue(PKEY_Title, pv);

			propStore->Commit();
			propStore->Release();
		}

		// SHAddToRecentDocs will cause the games to be added to the Recent list, allowing the user to pin them.
		SHAddToRecentDocs(SHARD_LINK, link);
		link->Release();
		delete[] game;
		delete[] desc;
	}
}
Esempio n. 5
0
BOOL Entry::launch_entry(HWND hwnd, UINT nCmdShow)
{
	TCHAR cmd[MAX_PATH];

	if (!get_path(cmd, COUNTOF(cmd)))
		return FALSE;

	 // add path to the recent file list
	SHAddToRecentDocs(SHARD_PATH, cmd);

	  // start program, open document...
	return launch_file(hwnd, cmd, nCmdShow);
}
Esempio n. 6
0
HRESULT CTaskbar7::AddRecent(BSTR name, BSTR path, BSTR arguments, BSTR icon)
{
	USES_CONVERSION;

	// ANSI version doesn't seem to work correctly with Win7 jump lists, so explicitly use Unicode interface.
	IShellLinkW *pShellLink = NULL;
	IPropertyStore *pPropertyStore = NULL;
	PROPVARIANT propVariant;

	HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pShellLink));
	EXIT_ON_ERROR(hr);

	// Path
	hr = pShellLink->SetPath(path);
	EXIT_ON_ERROR(hr);

	// Arguments
	hr = pShellLink->SetArguments(arguments);
	EXIT_ON_ERROR(hr);

	// Icon Location
	hr = pShellLink->SetIconLocation(wstring(icon).empty() ? path : icon, 0);
	EXIT_ON_ERROR(hr);

	hr = pShellLink->QueryInterface(IID_PPV_ARGS(&pPropertyStore));
	EXIT_ON_ERROR(hr);

	// Name
	hr = InitPropVariantFromString(name, &propVariant);
	EXIT_ON_ERROR(hr);

	hr = pPropertyStore->SetValue(PKEY_Title, propVariant);
	EXIT_ON_ERROR(hr);

	hr = pPropertyStore->Commit();
	EXIT_ON_ERROR(hr);

	// SHAddToRecentDocs will cause the link to be added to the Recent list, allowing the user to pin them.
	SHAddToRecentDocs(SHARD_LINK, pShellLink);

Exit:
	PropVariantClear(&propVariant);

	SAFE_RELEASE(pPropertyStore);
	SAFE_RELEASE(pShellLink);

	return hr;
}
void QWinJumpListCategoryPrivate::addRecent(QWinJumpListItem *item)
{
    Q_ASSERT(item->type() == QWinJumpListItem::Link);
    wchar_t *id = 0;
    if (jumpList && !jumpList->identifier().isEmpty())
        id = qt_qstringToNullTerminated(jumpList->identifier());

    SHARDAPPIDINFOLINK info;
    info.pszAppID = id;
    info.psl =  QWinJumpListPrivate::toIShellLink(item);
    if (info.psl) {
        SHAddToRecentDocs(SHARD_APPIDINFOLINK, &info);
        info.psl->Release();
    }
    delete[] id;
}
Esempio n. 8
0
void RecentsMRL::addRecent( const QString &mrl )
{
    if ( !isActive || ( filter && filter->indexIn( mrl ) >= 0 ) )
        return;

#ifdef _WIN32
    /* Add to the Windows 7 default list in taskbar */
    char* path = make_path( qtu( mrl ) );
    if( path )
    {
        wchar_t *wmrl = ToWide( path );
        SHAddToRecentDocs( SHARD_PATHW, wmrl );
        free( wmrl );
        free( path );
    }
#endif

    int i_index = recents.indexOf( mrl );
    if( 0 <= i_index )
    {
        /* move to the front */
        recents.move( i_index, 0 );
        times.move( i_index, 0 );
    }
    else
    {
        recents.prepend( mrl );
        times.prepend( "-1" );
        if( recents.count() > RECENTS_LIST_SIZE ) {
            recents.takeLast();
            times.takeLast();
        }
    }
    VLCMenuBar::updateRecents( p_intf );
    save();
}
Esempio n. 9
0
//---------------------------------------------------------------------------
//Called by user to indicate that file have been used
void __fastcall TRecent::FileUsed(const String &FileName)
{
  if(FMaxFiles)
  {
    RemoveMenuItems();//Remove shown menu items
    ReadFromRegistry();//Read data to get changes made by other version of program
    int Index = FileIndex(FileName);//Get index of FileName in list
    if(Index == -1)//If FileName not in list
    {
      if(FileList.size() == static_cast<unsigned>(FMaxFiles))//If list is full
        FileList.pop_back();//Erase last file name in list
    }
    else
      FileList.erase(FileList.begin() + Index);//Remove FileName from list

    FileList.push_front(std::pair<String, TActionClientItem*>(FileName, NULL));//Add FileName to start of list
    SaveToRegistry();//Write new file list to registry
    ShowMenuItems();//Show new list of menu items
  }
  
  //Add Filename to recent documents list in the start menu
  if(FAddToRecentDocs)
    SHAddToRecentDocs(SHARD_PATH, FileName.c_str());
}
Esempio n. 10
0
void TaskList::addToRecentList(QString name, QString user, QString host, int port) {
	if (! bIsWin7)
		return;

	HRESULT hr;
	IShellLink *link = NULL;
	IPropertyStore *ps = NULL;
	PROPVARIANT pt;

	hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, __uuidof(IShellLink), reinterpret_cast<void **>(&link));
	if (!link || FAILED(hr))
		return;

	QUrl url;
	url.setScheme(QLatin1String("mumble"));
	url.setUserName(user);
	url.setHost(host);
	url.setPort(port);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
	QUrlQuery query;
	query.addQueryItem(QLatin1String("title"), name);
	query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
	url.setQuery(query);
#else
	url.addQueryItem(QLatin1String("title"), name);
	url.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
#endif

	QSettings settings(QLatin1String("HKEY_CLASSES_ROOT"), QSettings::NativeFormat);

	QString app = settings.value(QLatin1String("mumble/DefaultIcon/.")).toString();
	if (app.isEmpty() || ! QFileInfo(app).exists())
		app = QCoreApplication::applicationFilePath();

	link->SetPath(app.toStdWString().c_str());
	link->SetArguments(QString::fromLatin1(url.toEncoded()).toStdWString().c_str());

	hr = link->QueryInterface(__uuidof(IPropertyStore), reinterpret_cast<void **>(&ps));
	if (FAILED(hr)) {
		qFatal("TaskList: Failed to get property store");
		goto cleanup;
	}

	InitPropVariantFromString(name.toStdWString().c_str(), &pt);
	hr = ps->SetValue(PKEY_Title, pt);
	PropVariantClear(&pt);

	if (FAILED(hr)) {
		qFatal("TaskList: Failed to set title");
		goto cleanup;
	}

	hr = ps->Commit();
	if (FAILED(hr)) {
		qFatal("TaskList: Failed commit");
		goto cleanup;
	}

	SHAddToRecentDocs(SHARD_LINK, link);

cleanup:
	if (ps)
		ps->Release();
	if (link)
		link->Release();
}
Esempio n. 11
0
// Запрос на выполнение команды под номером cmdid
void Command(int cmdid)
{
 switch (cmdid)
  {
   case RUN_SCREENSAVER: // debug
    PostMessage(GetDesktopWindow(),WM_SYSCOMMAND,SC_SCREENSAVE,0);
    break;
   case SH_ICONS_DESKTOP:
    if (IsWindowVisible(FindWindow("Progman",NULL))) ShowWindow(FindWindow("Progman",NULL),SW_HIDE);
    else                                             ShowWindow(FindWindow("Progman",NULL),SW_SHOW);
    break;
   case SH_TASK_PANEL:
    if (IsWindowVisible(FindWindow("Shell_TrayWnd",NULL))) ShowWindow(FindWindow("Shell_TrayWnd",NULL),SW_HIDE);
    else                                                   ShowWindow(FindWindow("Shell_TrayWnd",NULL),SW_SHOW);
    break;
   case CLEAR_DOCUMENTS:
    SHAddToRecentDocs(SHARD_PATH,NULL);
    break;


/*
Вопрос: 

Как програмно перезагрузить Windows? Ответ: Используйте функцию ExitWindows(). В качестве первого параметра ей передается она из трех констант: 
   EW_RESTARTWINDOWS 
   EW_REBOOTSYSTEM 
   EW_EXITANDEXECAPP 
Второй параметр используется для перезагрузки компьютера в режиме эмуляции MS DOS. 

Пример:
  ExitWindows(EW_RESTARTWINDOWS, 0 );  

    
завеpшение сеанса: RUNDLL32.EXE shell32.dll,SHExitWindowsEx
выключение:        RUNDLL32.EXE shell32.dll,SHExitWindowsEx 1
Reboot:            RUNDLL32.EXE shell32.dll,SHExitWindowsEx 2

Без запpоса
завеpшение сеанса: RUNDLL32.EXE shell32.dll,SHExitWindowsEx 4
выключение:        RUNDLL32.EXE shell32.dll,SHExitWindowsEx 5
Reboot:            RUNDLL32.EXE shell32.dll,SHExitWindowsEx 6
*/
   case PC_SHUTDOWN:
    ExitWindowsEx(EWX_SHUTDOWN,0);
    break;
   case PC_RESTART:
    ExitWindowsEx(EWX_REBOOT,0);
    break;
   case PC_QUICKRESTART:
    ExitWindowsEx(EWX_FORCE|EWX_REBOOT,0);
    break;
   case PC_RESTARTOS:
   // ExitWindowsEx(EW_RESTARTWINDOWS,0);
    break;
   case PC_LOGOUT:
    ExitWindowsEx(EWX_LOGOFF,0);
    break;
   case CD_AUDIO_OPEN:
    mciSendString("Set cdaudio door open wait",NULL,0,GetDesktopWindow());
    break;
   case CD_AUDIO_CLOSE:
    mciSendString("Set cdaudio door closed wait",NULL,0,GetDesktopWindow());
    break;
   case CLEAR_RECYCLEDBIN:
    SHEmptyRecycleBin(NULL,NULL,SHERB_NOPROGRESSUI);
    break;
   case MONITOR_OFF:
    PostMessage(GetDesktopWindow(),WM_SYSCOMMAND,SC_MONITORPOWER,1);
    break;
   case MONITOR_ON:
    PostMessage(GetDesktopWindow(),WM_SYSCOMMAND,SC_MONITORPOWER,-1); 
    break;
   case CONTROL_PANEL:
    WinExec("control.exe",SW_SHOWNORMAL);
    break;
   case MINIMIZE_ALL_WINDOWS:
    PostMessage(FindWindow("Shell_TrayWnd",NULL),WM_COMMAND,0x019F,0);
    break;
   case SHOW_TASK_LIST:
    PostMessage(GetDesktopWindow(),WM_SYSCOMMAND,SC_TASKLIST,0);
    break;

   case CONTROL_INSTALLPROGRAMS:
    WinExec("control.exe appwiz.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_SCREENSETTINGS:
    WinExec("control.exe desk.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_FINDFAST:
    WinExec("control.exe findfast.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_IESETTINGS:
    WinExec("control.exe inetcpl.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_LANGUAGE:
    WinExec("control.exe intl.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_GAMEDEVICES:
    WinExec("control.exe joy.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_MOUSE:
    WinExec("control.exe mouse",SW_SHOWNORMAL);
    break;
   case CONTROL_MULTIMEDIA:
    WinExec("control.exe mmsys.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_MODEM:
    WinExec("control.exe modem.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_NETWORK:
    WinExec("control.exe netcpl.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_PASSWORDS:
    WinExec("control.exe password.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_POWERSETTINGS:
    WinExec("control.exe powercfg.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_SCANERS_AND_CAMERAS:
    WinExec("control.exe sticpl.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_SYSTEM:
    WinExec("control.exe sysdm.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_TELEPHONE:
    WinExec("control.exe telephon.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_THEMES:
    WinExec("control.exe themes.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_DATATIME:
    WinExec("control.exe timedate.cpl",SW_SHOWNORMAL);
    break;
   case CONTROL_KEYBOARD:
    WinExec("control.exe keyboard",SW_SHOWNORMAL);
    break;
   case CONTROL_PRINTERS:
    WinExec("control.exe printers",SW_SHOWNORMAL);
    break;
   case CONTROL_FONTS:
    WinExec("control.exe fonts",SW_SHOWNORMAL);
    break;
   case CONTROL_SOUND:
    //WinExec("control.exe",SW_SHOWNORMAL);
    break;
   case CONTROL_USERS:
    //WinExec("control.exe",SW_SHOWNORMAL);
    break;
   case CONTROL_MAIL:
    //WinExec("control.exe",SW_SHOWNORMAL);
    break;
   case CONTROL_INSTALLHARDWARE:
    //WinExec("control.exe",SW_SHOWNORMAL);
    break;
    
    // Реакция на постороннее сообщение (на всякий случай)
   default:
    break;
  }
}
Esempio n. 12
0
void GHOST_SystemPathsWin32::addToSystemRecentFiles(const char* filename) const
{
	/* SHARD_PATH resolves to SHARD_PATHA for non-UNICODE build */
	SHAddToRecentDocs(SHARD_PATH,filename);
}