CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Jul 2006
    Posts
    10

    Wink launching a program without black DOS box

    I tried system("c:\\....exe") and ShellExecute("c:\....exe") but both of them shows a black DOS box.. I want do launch the program directly

  2. #2
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: launching a program without black DOS box

    first this shuld be in win32 forum .
    second the block box is from the exe?
    third tried createproccess?

  3. #3
    Join Date
    Jul 2006
    Posts
    10

    Re: launching a program without black DOS box

    yes it is an exe file. How can I use createprocess?

  4. #4
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: launching a program without black DOS box

    the black box is from the exe?

  5. #5
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: launching a program without black DOS box

    Pass DETACHED_PROCESS as dwCreationFlags in CreateProcess.
    http://msdn.microsoft.com/library/de...ateprocess.asp

    Don't forget to call CloseHandle on both PROCESS_INFORMATION::hProcess and PROCESS_INFORMATION::hThread
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  6. #6
    Join Date
    Aug 2005
    Posts
    478

    Re: launching a program without black DOS box

    Or CREATE_NO_WINDOW as dwCreationFlags. Either way.

    http://msdn.microsoft.com/library/de...tion_flags.asp

  7. #7
    Join Date
    Jul 2006
    Posts
    10

    Re: launching a program without black DOS box

    Quote Originally Posted by Mitsukai
    the black box is from the exe?
    no. it is a windows application.

  8. #8
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: launching a program without black DOS box

    Maybe SW_HIDE in ShellExecute (not sure, didn't do Win API programming for some time).
    "Programs must be written for people to read, and only incidentally for machines to execute."

  9. #9
    Join Date
    Jul 2006
    Posts
    10

    Re: launching long path programs

    I want to launch an application with path C:\Program Files\Firm Name\Program Name.exe. I think it does not work because path contains spaces

    i tried system(c:\\program files\\firm name\\program name.exe);
    also system(C:\\progra~1\firmna~1\progra~1.exe (not compiling));

  10. #10
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: launching a program without black DOS box

    Forgot ""? Also you should enclose it in "" in command line, to distinguish path to executable from its command line parameters, so it'll look this way:
    Code:
    system("\"C:\\Program Files\\Firm Name\\Program Name.exe\"");
    (note \")
    "Programs must be written for people to read, and only incidentally for machines to execute."

  11. #11
    Join Date
    Jul 2006
    Posts
    10

    Re: launching a program without black DOS box

    thank you it worked. also I found the total solution

    to launch a windows program witout a black dos box, with parameters:

    WinExec("C:\\Program Files\\My Application\\My App.exe C:\\foobar.tmp",SW_SHOWNORMAL)

  12. #12
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: launching a program without black DOS box

    It really works with spaces in directory names?
    "Programs must be written for people to read, and only incidentally for machines to execute."

  13. #13
    Join Date
    Feb 2005
    Location
    Normandy in France
    Posts
    4,590

    Re: launching a program without black DOS box

    Quote Originally Posted by RoboTact
    It really works with spaces in directory names?
    Yep, that's a security flaw.
    In order to avoid bugs written by bad programmers (especially Windows 3 programmers who assumed that most people don't put spaces in file names which was false, even in those early days), Windows first tries to search for a C:\Program.exe or C:\Program.com file, and if it doesn't exist, it tries C:\Program Files\My.exe (or .com), and then, C:\Program Files\My Application\My.exe (or .com), then, C:\Program Files\My Application\My App.exe. And, if it didn't exist, it would try C:\Program Files\My Application\My App.exe C:\foobar.tmp which is an invalid path, anyway.

    This flaw can be exploited by malicious software.
    "inherit to be reused by code that uses the base class, not to reuse base class code", Sutter and Alexandrescu, C++ Coding Standards.
    Club of lovers of the C++ typecasts cute syntax: Only recorded member.

    Out of memory happens! Handle it properly!
    Say no to g_new()!

  14. #14
    Join Date
    Jun 2002
    Location
    Moscow, Russia.
    Posts
    2,176

    Re: launching a program without black DOS box

    One more example of "silently accept buggy input" strategy - though with such approach something sloppy is simplier to make work it tends to stay at that sloppy level.
    "Programs must be written for people to read, and only incidentally for machines to execute."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured