Complete compilable createProcess Example needed

This is a discussion on Complete compilable createProcess Example needed within the Windows Programming forums, part of the Platform Specific Boards category; I am in need of a complete compilable version of createProcess. I am trying to send the Process to a ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Complete compilable createProcess Example needed

    I am in need of a complete compilable version of createProcess. I am trying to send the Process to a windows stat(0) handle to be seen on the desktop. I have not been able to find one working example. Thanks in advance for the help.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Rephrase the question. I don't have the slightest idea of what you want.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Washington D.C.
    Posts
    25
    Quote Originally Posted by CornedBee
    Rephrase the question. I don't have the slightest idea of what you want.
    He wants a working Example of CreateProcess, actually being used and creating the process.

    Throw this code into WinMain, and test (you'll have to change what I set hotkeyexe to, as im pretty sure thats not an executable on most person's systems), I've copied it straight out of one of my projects:

    Code:
    char *hotkeyexe = "NameOfYourProgramHere.exe";
    PROCESS_INFORMATION pi;
    STARTUPINFO si;
    
    CreateProcess(hotkeyexe, "", 0, 0, 0, 0, 0, 0, &si, &pi);

  4. #4
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Does this help

    Well I don't even know how to really ask the right question because my dad understands it better than me. I think he is trying to make a program come up on his networked computer by creating a process and then moving it to the window Station(0) handle so the application can be seen on his desktop no matter what. He doesn't want it to run just behind the scenes.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Maybe you should have your Dad post here then, because I have no clue what you are attempting to do.

    creating a process and then moving it to the window Station(0) handle
    You need to rephrase this.

  6. #6
    Registered User
    Join Date
    Jan 2006
    Posts
    29
    Ok... i have no clue of what you are asking here but maybe just guessing u want the application visible and opened on the desktop (foreground).

    Code:
    WinExec("C:\\Program Files\\MyApp.exe" , SW_SHOW);
    SW_FORCEMINIMIZE
    Windows 2000/XP: Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread.
    SW_HIDE
    Hides the window and activates another window.
    SW_MAXIMIZE
    Maximizes the specified window.
    SW_MINIMIZE
    Minimizes the specified window and activates the next top-level window in the Z order.
    SW_RESTORE
    Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
    SW_SHOW
    Activates the window and displays it in its current size and position.
    SW_SHOWDEFAULT
    Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application.
    SW_SHOWMAXIMIZED
    Activates the window and displays it as a maximized window.
    SW_SHOWMINIMIZED
    Activates the window and displays it as a minimized window.
    SW_SHOWMINNOACTIVE
    Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
    SW_SHOWNA
    Displays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated.
    SW_SHOWNOACTIVATE
    Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except the window is not actived.
    SW_SHOWNORMAL
    Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.

    try this and let me know if you are any close to what you want to do.

  7. #7
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I think you may be asking how to launch an interactive program from a service. This is a massive security hole and for that reason will not be possible in future Windows versions. That being said, the code looks something like this:
    Code:
    STARTUPINFO         si = { 0 };
    PROCESS_INFORMATION pi = { 0 };
    
    si.cb = sizeof(si);
    /* Use the interactive desktop rather than the current desktop.
     * WARNING: Security vulnerability! */
    si.lpDesktop = TEXT("Winsta0\\Default"); 
    
    CreateProcess(szProgramPath, szCommandLine,
                  NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
    
    CloseHandle(pi.hThread);
    CloseHandle(pi.hProcess);
    See this page for more information.
    Last edited by anonytmouse; 01-17-2006 at 05:00 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateProcess with arguments
    By Niara in forum Windows Programming
    Replies: 14
    Last Post: 09-08-2007, 06:41 AM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 11:44 AM
  3. CreateProcess
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 05-12-2002, 07:45 AM
  4. Doom Lord engine complete!
    By Leeman_s in forum Game Programming
    Replies: 8
    Last Post: 05-12-2002, 01:44 AM
  5. doom lord engine complete!
    By Leeman_s in forum C++ Programming
    Replies: 4
    Last Post: 04-25-2002, 09:41 PM

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