Thread: Can you execute any windows program?

  1. #1

    Can you execute any windows program?

    I was just wondering if there is a way to execute any program installed on your computer (or shortcut to a program), using Visual C++ (with MFC).

    I want to be able to execute a shortcut because some shortcuts allow extra parameters to be included. For instance I have a short cut to Half Life (a game) that starts up a map ('level') that I made, instead of loading the regular game.

    Ok thanks.

  2. #2
    I'm Back
    Join Date
    Dec 2001
    maybe you can use the system command...


  3. #3
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    You want to look into the system() or spawn() commands I think. I don't know of anything that will actually let you execute another shortcut, those commands can be used to execute a program directly; you'd need to give them details of the parameters you want to pass. Something like the following should work.

    #include <stdlib.h>
    int main (void)
    system ("c:\sierra\halflife\hl.exe -game cstrike");
    return (EXIT_SUCCESS);
    Demonographic rhinology is not the only possible outcome, but why take the chance

  4. #4
    Alright I shall try these things out, thanks for replying to my post. I will tell you how things go, or anything I find interesting.

  5. #5
    How come using only single slashes doesn't work?
    Using two is dumb

  6. #6
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Either \\ or / is acceptable.

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    I once wrote a function that parsed shortcut's for their target filename. It wasn't that difficult either. Tip: read the shortcut into an array and study the numerical values of the bytes. I can't remember now, but I think that the byte preceding the target name was a numerical 10 or 16....
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 01-01-2007, 06:36 AM
  2. Replies: 2
    Last Post: 12-22-2006, 07:45 PM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  4. Simple Windows Program - text?
    By Doagie in forum Windows Programming
    Replies: 1
    Last Post: 11-27-2004, 01:21 AM
  5. Execute from another program using C#
    By Grayson_Peddie in forum C# Programming
    Replies: 4
    Last Post: 05-04-2003, 12:03 PM