Thread: executing program....

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    16

    executing program....

    hi,
    2. I have problem when executing program from windows, I use: system("c:\\windows\\Notepad.exe"); and all is ok but that stupid dos box appears when notepad is executed, now the question, how to execute program without dos box???

    2. I used ShellExecute but got an error while compiling:
    "passing `const char *' as argument 1 of `ShellExecuteA(HWND__ *, const CHAR *, const CHAR *, const CHAR *, const CHAR *, int)'" so whats the syntax of ShellExecute ??
    Last edited by Turek; 07-29-2002 at 01:21 AM.

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    16
    ok I solved the problem, sorry for messing up
    ShellExecute(HWND_DESKTOP,"open","c:\\windows\\Not epad.exe",NULL,NULL,SW_SHOWNORMAL);

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    3
    You can also use WinExec("notepad.exe", SW_SHOWNORMAL);
    or WinExec("notepad.exe path_file.txt", SW_SHOWNORMAL);

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    16
    of course i can, thanks

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    WinExec( ) is for 16-bit compatibility though... You should really start using CreateProcess for the newer Windows OS's...
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    16
    so what is the syntax of CreateProcess?? and what library to use it with (*.h)

  7. #7
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Code:
    BOOL CreateProcess(
      LPCTSTR lpApplicationName,                 // name of executable module
      LPTSTR lpCommandLine,                      // command line string
      LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
      LPSECURITY_ATTRIBUTES lpThreadAttributes,  // SD
      BOOL bInheritHandles,                      // handle inheritance option
      DWORD dwCreationFlags,                     // creation flags
      LPVOID lpEnvironment,                      // new environment block
      LPCTSTR lpCurrentDirectory,                // current directory name
      LPSTARTUPINFO lpStartupInfo,               // startup information
      LPPROCESS_INFORMATION lpProcessInformation // process information
    );
    Imported from Kernel32 (so you dont need any more libs that a standard project) and defined under windows.h

    Its a complex and very powerful func....

    For Shell Execution I prefer...er...ShellExecute() as it can run documents and launch a program based on extension settings

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 40
    Last Post: 09-01-2006, 12:09 AM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Executing a program
    By trancedeejay in forum C Programming
    Replies: 7
    Last Post: 03-06-2006, 08:55 AM
  4. Problem executing sample program:
    By mrabiu in forum C++ Programming
    Replies: 4
    Last Post: 03-13-2004, 06:44 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM