How do I write a program in C++ or C# that launches applications on Windows Vista?
For example launching Dreamweaver CS 4 ("C:\Program Files\Adobe\Adobe Dreamweaver CS4\Dreamweaver.exe) and place it on top with the BringWindowToTop-function?
How do I write a program in C++ or C# that launches applications on Windows Vista?
For example launching Dreamweaver CS 4 ("C:\Program Files\Adobe\Adobe Dreamweaver CS4\Dreamweaver.exe) and place it on top with the BringWindowToTop-function?
In c#
Process.Start("c:\whatever\somefile.exe", <commandline args>);
should do it
In C/C++ there are plenty ways to do that.
system("c:\whatever\somefile.exe");
should fire up the program whatever you want.
using System; using System.Diagnostics;
namespace Launcher
{
public static class Program
{
public static void Main(string[] args)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = args[0];
startInfo.WindowStyle = ProcessWindowStyle.Normal;
Process.Start(startInfo);
}
}
}
The main problem that you'll have is finding out which new window belongs to the just-created process. A simple solution would be to EnumWindows()
before and after, and then raise the newly created top-level window. Since your launcher presumably has the focus, it can give that focus to the new window.
Not C++ or C# but, using AutoIt, you can launch the program and either automate the click you make or bring to top the DW4 window, for example (not tested):
AutoItSetOption("WinTitleMatchMode", 2)
Run("C:\Program Files\Adobe\Adobe Dreamweaver CS4\Dreamweaver.exe", "", @SW_MAXIMIZE)
WinSetOnTop("Dreamweaver", "", 1)
and once the script suits your need there's a tool to convert it to an exe (Aut2Exe). Hope that helps :)
To launch the program use: Process.Start
.
To find the path of the exe file, you may have a look at the registry.
I would recommend to manually search in the registry the actual path of the exe in you computer, and this way try to see where the path is saved.
To bring to window to the front, you can use SetForegroundWindow(int hWnd)
as well as FindWindow(string lpClassName, string lpWindowName)
, as mentioned here:
http://www.dotnetspider.com/resources/5772-Bring-e-window-Front-set-It-Active-window.aspx
Hopes it helps.