#include <windows.h>
#include <shellapi.h>

int main(int argc, char* argv[])
{
	ShellExecute(NULL,"open","C:/Windows/System32/calc.exe",NULL,"C:/Windows/System32/",SW_HIDE);
	Sleep(1000);
	ShowWindow(FindWindow(NULL, "Calculator"), SW_HIDE);
	return 0;
}

ok well if i dont have the sleep(1000); there it doesnt hide the window.
i want it to load the window hidden, not hide it once its loaded.

Does anyone have any suggestions.

Note: I have also tried CreateProcess() with the startup params.

Didn't the startup params in CreateProcess() work?

nope......

It is not possible to start a new GUI program without a window. It only works for console programs.

Does anyone have any suggestions.

Whether or not a given application starts up as hidden depends on how the application is coded. I.e. it may be that calc, for example, ensures that it starts up with a visible window.

what about for example, internet explorer or firefox?

i know hiding firefox/internet explorer on startup (ie it doesnt show at all) is possible in VB but why doesn't it work for c++?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.