Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Other Forums > Chit-Chat


Chit-Chat Relax for a bit and have a general conversation (off topic is allowed!) with other members. Please be polite and respect your fellow members.

Reply
 
Thread Tools Display Modes
Old 29th August 2005, 08:48 PM   (permalink)
Exo
Default

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.
Exo is offline   Reply With Quote
Old 30th August 2005, 12:52 PM   (permalink)
Default

i prefer c to c++ because c is more simple than c++ and does the some job.
__________________
when you post that reply, im just kidding.
danielsmusic is offline   Reply With Quote
Old 30th August 2005, 08:30 PM   (permalink)
Exo
Default

MFC is based upon object oriented programming.
The only way to write MFC applications is in C++, it's not possible in C.
Exo is offline   Reply With Quote
Old 31st August 2005, 02:10 PM   (permalink)
Default

so that means the code i writen won't work
__________________
when you post that reply, im just kidding.
danielsmusic is offline   Reply With Quote
Old 31st August 2005, 08:55 PM   (permalink)
Exo
Default

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.
Exo is offline   Reply With Quote
Old 1st September 2005, 10:51 PM   (permalink)
Default

isnt it possible to do it in the regestry to hide it to the tray :?:
__________________
when you post that reply, im just kidding.
danielsmusic is offline   Reply With Quote
Old 7th September 2005, 10:48 AM   (permalink)
Default

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?
__________________
May God be with you.
My Blog
Agent 009 is offline   Reply With Quote
Old 10th September 2005, 01:02 PM   (permalink)
Default

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.
__________________
Time is nature\'s way of keeping everything from happening at once.
http://membres.lycos.fr/jrainville/
Joel Rainville is offline   Reply With Quote
Old 10th September 2005, 01:04 PM   (permalink)
Default

Quote:
Originally Posted by Exo
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.
__________________
Time is nature\'s way of keeping everything from happening at once.
http://membres.lycos.fr/jrainville/
Joel Rainville is offline   Reply With Quote
Old 10th September 2005, 01:16 PM   (permalink)
Default

im on xp pro, what demo program?
__________________
when you post that reply, im just kidding.
danielsmusic is offline   Reply With Quote
Old 10th September 2005, 01:22 PM   (permalink)
Default

Quote:
Originally Posted by danielsmusic
im on xp pro, what demo program?
Create a new console app project, paste the code in and compile. There's your demo.

Note that it doesn't work when launched from Visual Studio's IDE. You need to launch (double-click or run from the command line) the .exe yourself. When launched from the IDE, the title bar text is enclosed in double quotes...
__________________
Time is nature\'s way of keeping everything from happening at once.
http://membres.lycos.fr/jrainville/
Joel Rainville is offline   Reply With Quote
Old 10th September 2005, 02:40 PM   (permalink)
Default

thanks,
i needed to shutdown my computer from another room so i will create a program that will read commands from a file and the other program will write to that file remotely.

i have ideas for it.
__________________
when you post that reply, im just kidding.
danielsmusic is offline   Reply With Quote
Old 12th September 2005, 09:15 PM   (permalink)
Default

Did u ever considered remote desktop connection? Maybe that'll solve all and many other of ur problems :wink: :!:
__________________
May God be with you.
My Blog
Agent 009 is offline   Reply With Quote
Old 13th September 2005, 09:37 AM   (permalink)
Default

Quote:
Originally Posted by danielsmusic
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
The obvious question to this problem is, are you using the same username/password combination on both computers? If you're logged on to PC1 as "bob" and try to shutdown PC2 remotely, PC2 needs a user account "bob" with the same password as "bob" on PC1. "bob" would also need the correct permissions to do this.
kazakhan is offline   Reply With Quote
Old 14th September 2005, 07:41 PM   (permalink)
Default

yea :evil: , why don't microsoft make anything simple? i get that same answer when i google around. thanks for the post though :wink:
__________________
when you post that reply, im just kidding.
danielsmusic is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 11:55 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.