• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

hide the dos windows when my application is launched

Hello Experts
how can i hide my dos windows when my application is running?
I am using Dev c++ as compiler
i tried
int WINAPI WinMain (HINSTANCE,  HINSTANCE, LPSTR, int)

 my code here

return 0;

but it seems not working yet
0
kagami01
Asked:
kagami01
  • 7
  • 6
  • 2
  • +1
1 Solution
 
ZoppoCommented:
Hi kagami01,

I'm not sure if this works, but you can give it a try: With 'GetConsoleWindow' you should be able to retrieve the HWND of the DOS-window, then you can ShowWindow( ..., SW_HIDE ); to hide it.

Hope that helps,

ZOPPO
0
 
kagami01Author Commented:
you mean like the code below here:
int WINAPI WinMain( HINSTANCE,  HINSTANCE, LPSTR, int)
 
 
{
  
  HWND Console;             
  AllocConsole ();
  Console=FindWindowA ("ConsoleWindowClass",NULL);
  ShowWindow (Console,SW_HIDE);
 
 
 my other c++ code here
 
 
 return 0;
}

Open in new window

0
 
ZoppoCommented:
Yes, it might be this works (never tried this before, so I'm not sure) ...
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
kagami01Author Commented:
maybe i's ok but it's not running on vista
anywya any other solutins beside that?
0
 
Mark_FreeSoftwareCommented:
set your project type to a normal windows application instead of a console application
0
 
kagami01Author Commented:
already settled to windows application but i didn't marked the "XP teme" option
anyway it's not working yet on Vista
0
 
ZoppoCommented:
Sorry, seems I didn't read you code-snippet carefully - you use 'FindWindowA', but I suggested to use 'GetConsoleWindow'.

So, it should be:

HWND console = GetConsoleWindow();
if ( NULL != console )
{
 ::ShowWindow( console, SW_HIDE );
}

ZOPPO
0
 
kagami01Author Commented:
that code has caused many erros while the compiling
0
 
ZoppoCommented:
Hm - to get 'GetConsoleWindow' compiled you need to define _WIN32_WINNT as 0x0500 or to retrieve the function pointer 'manually' using LoadLibrary and GetProcAddress.
0
 
kagami01Author Commented:
i have dev c ++ plus as compiler how can i fix it?
0
 
kagami01Author Commented:
i got this error:

`GetConsoleWindow' undeclared (first use this function)
0
 
ZoppoCommented:
I'm not sure since I never used dev c++ - anyway, LoadLibrary and GetProcAddress are Win32-API functions, so you should be able to use them ...
0
 
ZoppoCommented:
Yes, you get this since either you have a old SDK or _WIN32_WINNT is less than 0x0500.
0
 
itsmeandnobodyelseCommented:
>>>> how can i hide my dos windows when my application is running?
How do you invoke your application?

Should it run in background with no user interface? Or does it has a window to show? Or do you start it in a console (DOS Box) and you don't want a further console to pop-up?
0
 
kagami01Author Commented:
Dear Zoppo you were right i forgot the put
 #define _WIN32_WINNT 0x500 before the #include <windows.h>
 and i added in dev c++ in "tools"--->"option compilation"--> "-lgdi32"
so the i compiled the exe without problem and it worked for win vista thank you so much Zoppo.

question?!?!?!

i got a file after the compiling like follow:

Myapplication.exe.Manifest

i need it in in where the .exe folder is  or not??

0
 
itsmeandnobodyelseCommented:
>>>> i need it in in where the .exe folder is  or not??
Yes. The .manifest is some kind of configuration file where parts of the information was stored that formerly was in Windows registry.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 7
  • 6
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now