Can you execute any windows program?

This is a discussion on Can you execute any windows program? within the C++ Programming forums, part of the General Programming Boards category; I was just wondering if there is a way to execute any program installed on your computer (or shortcut to ...

  1. #1
    Shadow12345
    Guest

    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
    Posts
    556
    maybe you can use the system command...

    system("C:\\GAMES\\HALFLIFE\\HALFLIFE.EXE");

  3. #3
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    Posts
    236
    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.

    Code:
    #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
    Shadow12345
    Guest
    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
    Shadow12345
    Guest
    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
    Posts
    802
    Either \\ or / is acceptable.

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,600
    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....
    Code:
    if( numeric_limits< byte >::digits != bits_per_byte )
        error( "program requires bits_per_byte-bit bytes" );
    24bbs.cpp

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21