?
Solved

Hide a CPL during CreateProcess

Posted on 1999-12-21
10
Medium Priority
?
1,099 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:joeslow
  • 6
  • 4
10 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2298731
The problem here is that timedate.cpl is launched by Rundll32.exe. SW_HIDE specifies Rundll32.exe to be hidden.
0
 

Author Comment

by:joeslow
ID: 2298742
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
 
LVL 23

Expert Comment

by:chensu
ID: 2298786
Why do you want to hide it?
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 

Author Comment

by:joeslow
ID: 2298864
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
 
LVL 23

Expert Comment

by:chensu
ID: 2298891
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
 

Author Comment

by:joeslow
ID: 2298909
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
 
LVL 23

Expert Comment

by:chensu
ID: 2298978
Try

::ShellExecute(hWnd, NULL, _T("timedate.cpl"), NULL, NULL, SW_HIDE);
0
 
LVL 23

Expert Comment

by:chensu
ID: 2298991
That may not work. You may have to end up using FindWindow and ShowWindow(SW_HIDE).
0
 

Author Comment

by:joeslow
ID: 2299025
I think I am getting this error:
#define SE_ERR_NOASSOC                  31
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2299059
Yeah, it works on Windows 2000 only but it is still not hidden. FindWindow seems to be the only way.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question