Thread: running an external exe file

  1. #1
    Registered User
    Join Date
    Oct 2004

    running an external exe file

    Hi all,

    When my program starts i want it to run notepad so notepad suddenly appears on the screen. I tried

    LoadLibraryEx("c:/windows/notepad.exe", NULL, NULL);

    but no luck. Any ideas.

    For those of you that know VB then im looking for the c++ equivelant of



  2. #2
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Manassas, VA USA
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  3. #3
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    what if the file is in the same directory as the program but you dont know the exact location?

  4. #4
    Registered User
    Join Date
    Sep 2001
    You can sometimes get the directory of the current program from looking at the first entry in argv - though it's more reliable to use functions like the ones provided with the system SDK (in this case - Win32 - and I know it provides a function to find the directory of the current program).

    Since the OS is far more likely to have default directories set up than to actually use "windows" as the system folder, I would just use
    There are plenty of system out there that use "Win95" or "Win98" as the system folder.

    Don't forget to read up on the potential problems that inherently come with the use of system():

  5. #5
    Registered User
    Join Date
    Jun 2004
    Quote Originally Posted by The Brain
    system pops up an annoing command line window...

    Check these references

    a quick note

    if you use CreateProcess mind this
    CreateProcess("app.exe","app.exe arg1 arg2 ...", ... );
    yes, you must include the exe's name on both parameters.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  3. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  4. How do I execute an external EXE file
    By Scripter in forum C Programming
    Replies: 1
    Last Post: 11-09-2002, 07:02 AM
  5. running a external file
    By krappykoder in forum C++ Programming
    Replies: 5
    Last Post: 06-14-2002, 07:19 PM