Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

c++ hidden?

Status
Not open for further replies.
Well it's just simple..You can use the simple hide/show function of the application in order to do hide it. It will only disappear but still work in the background...Sorry but i dont have in mind the exact name of the function but try to search on it
 
Ok, and that function obviously requires a window handle, wich is why it cannot work on a handle-less console application...

Post the function information if you find it. It would be a handy trick to know :wink:
 
Yep, a window handle is necessary,call it hwnd
so in order to hide the application, all u have to do is to call this function ShowWindow(hwnd,SW_HIDE);

In fact, i stopped my C++ programming regarding API because it's completely a maze. Regarding API, i'm using Java. But C++ still the engineer's favorite :)
 
Yeah, that works :)
I can start writing a virus now :twisted: ...

not that i'm going too :)

@Danielsmusic: Now you know what funtion to use to hide your program - if you don't know how to get your program ported to MFC and use this function then tell me.

Simplest would be to create a dialog based MFC application. ShowWindow() is a member of CDialog, the base class for the main dialog.
 
hehe I'm glad it worked...Well in my case, i didnt use it as a virus
I made a program that when u type a virtual key (say CTRL+h), it will hide all the opened programs, and another virtual key will show them again...that sounds tricky:p
God luck :D
 
that's not realy difficult is it :) ...
The missing link to do that was the above funtion, now that i know that it would be done in an instant.
 
Well, first of all you need to create a MFC application.
You can let the Appwizard do this, select 'File - New' and then 'MFC appwizard (exe)...

Select a dialog based application to keep it simple.

Now your code will need a bit of porting since you now have a event based window wich you must use to accept user input instead of a linear console application...

The ShowWindow() function is a member of the CWnd class, You can access it directly trough the main CDialog instance of your application as CDialog is derived from CWnd.
 
i still don't know what you mean.
when it come to visual programming i touch it and it does'nt work.
is this where i put the

HWIND hWind;

it just says it is a undeclared identifyer.

i don't know anything.


do you know how i can get the shutdown -s -f -m \\dan
working. all computers have pro on it just says, i don't have the right permision. i have looked up to 15 pages on google and i could not find anything that worked
 
Perhaps it would be easyer to find a site or a book about MFC ?
You can't expect to just jump into MFC and everything to work out.

You might also want to pick up a good c++ book.
All you've been doing up until now is writing C code and using a C++ compiler to compile it.
 
MFC is based upon object oriented programming.
The only way to write MFC applications is in C++, it's not possible in C.
 
It means you can't hide your program. You need a window handle for that, wich is only given to real windows applications, console applications have no handle.

The easyest and quickest way to write a windows program is by using MFC.
 
Are you using Microsoft's Visual C++ 6.0?
If u use .NET platform, I think u'll have no prob making the prog "invisible"... But it looks like u're using the Win32 Console Application, am I right?
 
danielsmusic,

You only want to hide your window? I thought you wanted the process to completely disappear (not listed in the Task Manager).

Hiding your window is pretty easy, and doesn't require MFC at all, even less so .NET... :roll:

You simply need to use the Win32 API directly (windows.h), and it can be done in a console app. Note that there must be hundreds of ways to do this. Here's one :

Code:
#include <windows.h>

int main(int argc, char* argv[])
{
	printf("Hello World!\n");

	Sleep( 2000 );

	HWND hw = FindWindow( "ConsoleWindowClass", "C:\\projects\\hidden\\release\\hidden.exe" );
	ShowWindow( hw, SW_HIDE );
	
	Sleep( 2000 );

	ShowWindow( hw, SW_SHOW );

	Sleep( 2000 );

	return 0;
}

The absolute path must be replaced by the complete text shown in your console app window's title bar. Don't assume it's the complete path to your .exe. Some versions of Windows show different information in the title bar of console apps.

It's not an elegant solution, but like I said, there are several ways to do this, I just never had to do this with a console app, so that's the best I can come up with off the top of my head. Maybe a Win32 guru will chime in.

You obviously only need those 2 lines :

Code:
   HWND hw = FindWindow( "ConsoleWindowClass", "C:\\projects\\hidden\\release\\hidden.exe" );
   ShowWindow( hw, SW_HIDE );

But if you compile the first code snippet, you will get a demo program that'll confirm this will work on your Windows version, which I don't believe you've mentioned so far?... It works on XP, and probably all NT based Windows. Not sure about 95/98/ME, but chances are good.
 
Exo said:
It means you can't hide your program. You need a window handle for that, wich is only given to real windows applications, console applications have no handle.

The easyest and quickest way to write a windows program is by using MFC.

Not true ;)

See previous post :cool:

Anything that shows on your desktop has a window handle. You just have to figure out a way to find it.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top