Hide a CPL during CreateProcess

I have a program that starts the TimeDate.cpl (control panel applet?).  I would like the Time/Date window to be hidden when it comes up.  The following is the code I use on a button click:

    STARTUPINFO startUpInfo;
    PROCESS_INFORMATION procInfo;
    BOOL success;

    GetStartupInfo(&startUpInfo);
    startUpInfo.dwFlags     &= STARTF_USESHOWWINDOW;
    startUpInfo.wShowWindow &= SW_HIDE;

    success =
    CreateProcess(
        0,                      // pointer to name of executable module
        "Rundll32.exe Shell32.dll,Control_RunDLL timedate.cpl",
                                // pointer to command line string
        0,                      // pointer to process security attributes
        0,                      // pointer to thread security attributes
        FALSE,                      // handle inheritance flag
        CREATE_NEW_CONSOLE,      // creation flags
        0,                      // pointer to new environment block
        0,                      // pointer to current directory name
        &startUpInfo,              // pointer to STARTUPINFO
        &procInfo               // pointer to PROCESS_INFORMATION
    );


It works, but the window is visible.  WHat am I doing wrong?

Thank you,
Joe
joeslowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

chensuCommented:
The problem here is that timedate.cpl is launched by Rundll32.exe. SW_HIDE specifies Rundll32.exe to be hidden.
0
joeslowAuthor Commented:
Is there a way to do what I want.  I am calling FindWindow to get the handle to it and then sending the SW_HIDE message to it? What I'd really like to do is not have it show at all...

Thank you,
Joe
0
chensuCommented:
Why do you want to hide it?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

joeslowAuthor Commented:
I am trying to control a .cpl application from my own application.  I am just using the TimeDate cpl to practice with until I get the real one.  The real one is too complex for most users and I am writing a "simpler" version that will control the real one (hopefully hidden from the user).  I don't have the source code for the .cpl.
0
chensuCommented:
Which cpl are you going to control? Can't you call Win32 API functions to achieve what you want? The way you are doing is not reliable.
0
joeslowAuthor Commented:
It's a third party cpl with no API of its own.  I am using Win32 API functions to emulate clicking buttons, turning pages, selecting items in combo boxes, etc.
0
chensuCommented:
Try

::ShellExecute(hWnd, NULL, _T("timedate.cpl"), NULL, NULL, SW_HIDE);
0
chensuCommented:
That may not work. You may have to end up using FindWindow and ShowWindow(SW_HIDE).
0
joeslowAuthor Commented:
I think I am getting this error:
#define SE_ERR_NOASSOC                  31
0
chensuCommented:
Yeah, it works on Windows 2000 only but it is still not hidden. FindWindow seems to be the only way.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.