Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. starting and controlling an application

starting and controlling an application

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    caykahve
    wrote on last edited by
    #1

    hi, using my program, i want to start an application, let's say internet explorer, or outlook. afterwards i want to set the focus to this application, move it, and maximize it. i need some help, and here are my questions: 1. to start the program i have tried this function, but it crashes. _wexeclp((wchar_t*)("C:/Program Files/Internet Explorer/iexplore.exe"),NULL); It says the arguement list cannot be NULL, but i do not know what to put there as argument. how can run another application? 2. what function can i use to get the path of the program files "C:\program files"? There is a function called "GetWindowsDirectory", but could not find one for program files. 3. after running the application, i am thinking of capturing it with a hook to set the focus on it, to move and change the size of it. is it right? is there a simpler solution? it won't not only internet explorer that needs to be started. i might need to start another program on some other user event. Thanks in advance caykahve

    G B T 3 Replies Last reply
    0
    • C caykahve

      hi, using my program, i want to start an application, let's say internet explorer, or outlook. afterwards i want to set the focus to this application, move it, and maximize it. i need some help, and here are my questions: 1. to start the program i have tried this function, but it crashes. _wexeclp((wchar_t*)("C:/Program Files/Internet Explorer/iexplore.exe"),NULL); It says the arguement list cannot be NULL, but i do not know what to put there as argument. how can run another application? 2. what function can i use to get the path of the program files "C:\program files"? There is a function called "GetWindowsDirectory", but could not find one for program files. 3. after running the application, i am thinking of capturing it with a hook to set the focus on it, to move and change the size of it. is it right? is there a simpler solution? it won't not only internet explorer that needs to be started. i might need to start another program on some other user event. Thanks in advance caykahve

      G Offline
      G Offline
      Geert van Horrik
      wrote on last edited by
      #2

      1. Check out the ShellExecuteEx() function 2. SHGetSpecialFolderPath(NULL, sTemp.GetBuffer(_MAX_PATH), CSIDL_PROGRAM_FILES, FALSE); 3. See 1 Geert Want to spread the newest version of your software automatically for free? Use Updater! Visit my website: www.gvhsoftware.org

      C 1 Reply Last reply
      0
      • C caykahve

        hi, using my program, i want to start an application, let's say internet explorer, or outlook. afterwards i want to set the focus to this application, move it, and maximize it. i need some help, and here are my questions: 1. to start the program i have tried this function, but it crashes. _wexeclp((wchar_t*)("C:/Program Files/Internet Explorer/iexplore.exe"),NULL); It says the arguement list cannot be NULL, but i do not know what to put there as argument. how can run another application? 2. what function can i use to get the path of the program files "C:\program files"? There is a function called "GetWindowsDirectory", but could not find one for program files. 3. after running the application, i am thinking of capturing it with a hook to set the focus on it, to move and change the size of it. is it right? is there a simpler solution? it won't not only internet explorer that needs to be started. i might need to start another program on some other user event. Thanks in advance caykahve

        B Offline
        B Offline
        bugDanny
        wrote on last edited by
        #3

        I wrote a similar program that the majority of its funcitonality is starting other programs and controlling where on the screen they are placed. 1. To start the other program I actually open up a batch file (.bat You can also use the .cmd extension now, too.) I write in a few lines to the batch file such as: cd "C:\Program Files" That line would change the directory to "Program Files". You can put in the path name of whatever program you want to start. And then: iexplore "http:\\www.google.com" That line would start internet explorer and bring it to the google page. 3. I use a function called EnumWindows(). This function will enumerate all the open windows on the machine. Look at MSDN for this, but you will have to write your own function to tell it what to DO with each window it checks, but in that function you can do something like EnumWindowsMine(HWND hWnd, LPARAM fail) and then use functions like GetWindowText() or GetClassName(). These also you can look up on MSDN. In this way, you can use either the class name of a window or the text of a window to check to see if this window is the one you want to target. And then you can use MoveWindow() (look this up) to put the window where you want it to. (I had to use ::, like ::MoveWindow(). You may have to, too.) If you want, you could put some of these statements into a loop, so it will loop until the program starts and it is put to where you want it. If you need to, you can use GetWindowRect() to see if the window you are checking is already in the right place. Many places you can go from here. Hope this helps. Yesterday is history, Tomorrow is a mystery, Today is a gift, That's why they call it the Present. Danny

        1 Reply Last reply
        0
        • C caykahve

          hi, using my program, i want to start an application, let's say internet explorer, or outlook. afterwards i want to set the focus to this application, move it, and maximize it. i need some help, and here are my questions: 1. to start the program i have tried this function, but it crashes. _wexeclp((wchar_t*)("C:/Program Files/Internet Explorer/iexplore.exe"),NULL); It says the arguement list cannot be NULL, but i do not know what to put there as argument. how can run another application? 2. what function can i use to get the path of the program files "C:\program files"? There is a function called "GetWindowsDirectory", but could not find one for program files. 3. after running the application, i am thinking of capturing it with a hook to set the focus on it, to move and change the size of it. is it right? is there a simpler solution? it won't not only internet explorer that needs to be started. i might need to start another program on some other user event. Thanks in advance caykahve

          T Offline
          T Offline
          Tom Wright
          wrote on last edited by
          #4

          caykahve wrote: 1. to start the program i have tried this function, but it crashes You want to use "CreateProcess", to start another program. caykahve wrote: 2. what function can i use to get the path of the program files "C:\program files"? There is a function called "GetWindowsDirectory", but could not find one for program files. Why do you need a function to find "C:\Program Files"? Program files is on the C:\ drive, according to what you are asking. It is, however possible to have program files on different drives. If it's that you want to know where the program is running from, well then you can use GetModuleFileName. caykahve wrote: 3. after running the application, i am thinking of capturing it with a hook to set the focus on it, to move and change the size of it. is it right? is there a simpler solution? it won't not only internet explorer that needs to be started. i might need to start another program on some other user event. Also since you started the program with create process you now have a handle to it. So you can call SetWindowPos to set the window were ever you want. Tom Wright tawright915@yahoo.com

          1 Reply Last reply
          0
          • G Geert van Horrik

            1. Check out the ShellExecuteEx() function 2. SHGetSpecialFolderPath(NULL, sTemp.GetBuffer(_MAX_PATH), CSIDL_PROGRAM_FILES, FALSE); 3. See 1 Geert Want to spread the newest version of your software automatically for free? Use Updater! Visit my website: www.gvhsoftware.org

            C Offline
            C Offline
            caykahve
            wrote on last edited by
            #5

            Thanks a lot. I can get the program files folder path, and can run other processes using ShellExecuteEx now. I can get the process handle as HANDLE, but how can I get the CWnd * of the windows that I open? I want to use SetWindowPos() function, therefore i need it. Thanks, Caykahve

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups