f



Problem getting console window handle

Need to get the window handle for a Win32 console app. According to a few 
websites, the following should work:

#include <windows.h>

HWND  hConsole    ;

int main()
{
 hConsole = GetConsoleWindow()    ;
........
}

But the compile reports an error:
error C2065: 'GetConsoleWindow' : undeclared identifier

The project link settings do include kernel32.lib, as instructed.

Any assistance much appreciated. 


0
Bruce
4/21/2013 7:21:02 AM
comp.os.programmer.win32 14523 articles. 0 followers. Post Follow

2 Replies
637 Views

Similar Articles

[PageSpeed] 55

>But the compile reports an error:
>error C2065: 'GetConsoleWindow' : undeclared identifier

Check the remarks section of the documentation:
http://msdn.microsoft.com/en-gb/library/windows/desktop/ms683175(v=vs.85).aspx

You will of course need to be using tools that post-date Windows 2000
to have the header definition & lib.

Dave
0
David
4/21/2013 8:39:52 AM
On Sun, 21 Apr 2013 15:21:02 +0800, "Bruce Varley" <bv@NoSpam.com>
wrote:

>Need to get the window handle for a Win32 console app. According to a few 
>websites, the following should work:
>
>#include <windows.h>
>
>HWND  hConsole    ;
>
>int main()
>{
> hConsole = GetConsoleWindow()    ;
>.......
>}
>
>But the compile reports an error:
>error C2065: 'GetConsoleWindow' : undeclared identifier
>
>The project link settings do include kernel32.lib, as instructed.
>
>Any assistance much appreciated. 
>

This is a compiler error, not a linker error, so don't fret about the
libs just yet, you haven't gotten that far.

You can use the Visual Studio IDE to jump to the definition of these
constants or you can add this to your source to verify David's
suggestion:

#ifndef  _WIN32_WINNT
#error  _WIN32_WINNT not defined
#endif

#ifndef  _WIN32
#error  _WIN32 not defined
#endif

#ifndef  _CONSOLE
#error  _CONSOLE not defined
#endif

These will stop compiliation if your project is incorrectly targeted.
0
Geoff
4/21/2013 4:40:32 PM
Reply:

Similar Artilces:

Problem with WIN32-Process and window handle
Hi all, how can I get the window handle of a process (i.E. Excel or others) started with Win32::Process ? Thanks Pit Hi, Pit wrote: > Hi all, > > how can I get the window handle of a process (i.E. Excel or others) > started with Win32::Process ? Not possible, take a look: http://www.codeguru.com/forum/showthread.php?s=&threadid=273507 (How can I get the window handle from process id) regards, Reinhard P.S: I have an module which deals with Windows, but not released at CPAN. Here you can get the window handle using the title of the window. The...

Getting console output from Win32 Windows application
Gentlefolk, is there a quick and easy way to get console output from a Win32 NON-console application? It would be really helpful for debugging purposes, rather than having to faff around with MessageBoxes and static controls. * Havatcha: > Gentlefolk, is there a quick and easy way to get console output from a > Win32 NON-console application? > > It would be really helpful for debugging purposes, rather than having to > faff around with MessageBoxes and static controls. Just write to standard output. Standard output works whether the subsystem is console ...

c++ win32 console app with configurable displaying of console window
Hi, This question has been asked before but what I'm doing is a slight twist on all of the questions/answers I've seen so far. I developing a c++ console app (has to be a console app, a wins service is no use to me) - I don't want the console window to be displayed when the app is running - I've seen on several posts how this can be done by changing a projects linker properties to the following /link /subsystem:windows /entry:mainCRTStartup. This does the job - however, I also want to be able to occasionally turn back on displaying of the console window at app startup ...

Getting handle on Handles?
I'm trying to create my own shellexecute program named shell4OD and am having problems with handles. Here is my code ... ===== Private Declare Function ShellExecute Lib _ "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As _ String, ByVal lpParameters As String, ByVal lpDirectory As String, _ ByVal nShowCmd As Long) As Long Public function Shell4OD( byVal cmd as string, byVal parameters as string, byVal Dir as string, byVal showHide as integer) As Boolean Dim procHandle As Long, shellHnd As Long, taskID As Long ' hmmm shellHnd = ???? <=== here is my problem taskID = ShellExecute( shellHnd, _ vbNull, cmd, parameters, Dir, showHide) ' get the process handle procHandle = OpenProcess(&H100000, True, taskID) Shell4OD = WaitForProcess( procHandle) ' close the handle CloseHandle procHandle end function ' Wait for a number of milliseconds, and return the running status ' of a process. If argument is omitted, wait untill the process ' terminates. Function WaitForProcess(taskId As Long, Optional msecs As Long = -1) _ As Boolean Dim procHandle As Long ' get the process handle procHandle = OpenProcess(&H100000, True, taskId) ' check for its signaled status, return to caller WaitForProcess = WaitForSingleObject(procHandle, msecs) <> -1 '...

gets problem in windows etcl
I have a problem with 'gets' in Evolane's etcl, but in Windows only: With puts [gets stdin] etcl immediately returns to the prompt. But I should be able to enter a line, shouln't I? I do suspect that there's something strange with the stdins of the etcls for Windows (this effect shows in etcl for 'normal' Windows as well as in the Windows Mobile version). Can anyone give me a hint what the problem might be? -Christoph. On 18 Dez., 12:58, Christoph <christoph.la...@gmail.com> wrote: > I have a problem with 'gets' in Evolane's etcl, but in Windows only: > With > > puts [gets stdin] > > etcl immediately returns to the prompt. But I should be able to enter > a line, shouln't I? I do suspect that there's something strange with > the stdins of the etcls for Windows (this effect shows in etcl for > 'normal' Windows as well as in the Windows Mobile version). > This is not eTcl-specific. Wish on Windows has the same problem: stdout and stderr are sent to the console, but stdin is on permanent EOF. See http://wiki.tcl.tk/10794 "gets workaround". On Dec 18, 2:10 pm, suchenwi <richard.suchenwirth- bauersa...@siemens.com> wrote: > On 18 Dez., 12:58, Christoph <christoph.la...@gmail.com> wrote:> I have a problem with 'gets' in Evolane's etcl, > but in Windows only: > [...] > > This is not eTcl-specific. Wish on Windows has the same prob...

Getting handle of Console app
How do you get the handle of a console app? I have a couple of library functions that I'd like to use the HWND in, but I'm not sure of how to get it. Any help would be appreciated. Thanks frank wrote: > How do you get the handle of a console app? I have a couple of library > functions that I'd like to use the HWND in, but I'm not sure of how to get > it. You mean a HWND to the console window? Beginning with Windows 2000 there is a function called GetConsoleWindow() that gives you the handle. On older Windows versions you can search for the h...

anybody knows the relationship of matlab figure window handle and Windows handle?
Is there any hidden undocumented API that can convert a matlab figure window handle into a Windows window handle? I mean, even Matlab itself should have a way to identify those figure windows, right? I used FindWindowEx in MSVC++ 7.0, but it does not always find the window on my windows XP... any help? >>> "lucy" <losemind@yahoo.com> seems to think that: >Is there any hidden undocumented API that can convert a matlab figure window >handle into a Windows window handle? > >I mean, even Matlab itself should have a way to identify those figure >window...

Enabling a Unix OS in dual boot config with a Windows OS to maintain a valid keytab in Active Directory without invalidating the Windows OS's domain trust relationship
Dear List, This information is aimed at sites for which all of the following apply: - Sites that are using Active Directory as a Kerberos KDC - Sites that have dual-boot configured machines running both a Linux and W= indows based OS with the same hostname - Sites that want to have a working Kerberos keytab on the Linux OS, but w= ithout invalidating the trust relationship between the Windows OS and Activ= e Directory. This problem may be old news or may not apply, but it can be solved with a = few steps: Problem/Background: If a keytab is constructed for the Linux OS (using mskt= util, ktpass etc), the password of the corresponding computer account is re= set in Active Directory in order for client and domain controller(s) to hav= e matching keys. This invalidates the Windows OS's password, which no longe= r matches the one stored in Active Directory. This results in the following= error when attempting to logon to the domain from the Windows OS: 'The trust relationship between this workstation and the primary domain fai= led' A Solution: Configure the Windows OS to use a password which matches that u= sed by the Linux OS (I used the NetJoinDomain function to do this). There i= s an increased security risk, in that the Windows OS can no longer periodic= ally update the key, but developing a custom key renewal system which does = not invalidate either OS's key might be an option. Steps: 1. Login as the local Administrator on the Windows OS 2. Disab...

Get Window handle from point #4
Hi, first sorry on awkward english. I'll try to illustrate my problem: (dont know how will this look on your scrren) |--Dialog----------------------------------------------------------------------------| | | | |-------groupbox---- -----------------------------------------------------| | | | | | | | | | | | |-------------------------------| | | | | | Button P(x,y) | | | | | |-------------------------------| | | | | ...

The Problem with Windows: one crappy OS!
In an effort to balance all the anti-Linux thread titles, let's start a few more accurately titled threads. Feel free to discuss this topic. Let's start with the fact that my XP system is getting more and more unstable with each new "patch". Prick Chaney wrote: > In an effort to balance all the anti-Linux thread titles, let's start a few > more accurately titled threads. > > Feel free to discuss this topic. Let's start with the fact that my XP system > is getting more and more unstable with each new "patch". > > > Learn how...

Get Context menu handle of window
Hi all, how to get handle of context menu of window or from window handle. OS is windows 10, and i am looking to get handle of context menu appearing over start menu. On Fri, 8 Jan 2016 02:44:43 -0800 (PST), manishsinghpatwal@gmail.com wrote: > Hi all, > > how to get handle of context menu of window or from window handle. OS is > windows 10, and i am looking to get handle of context menu appearing over > start menu. Any GDI handle is usable only within the process that created it. What are you try to do exactly? On 08/01/2016 10:44, manishsinghpatwal@gmail...

OS X gets more complex
It follows doesn't it? Trying to support Intel and PPC, OS X and Classic on PPC machines, Tiger and Leopard both in same updates. I'm sticking with Tiger as it works for me and I still haven't fully explored it - so I'm wary about software updating everything because the latest updates are primarily aimed at Leopard users. Apple tech support forums, MacFixit and other websites, blogs and newsgroups have reported increasing problems from users with older systems and conflicts with older software. Sounds kind of like Windows and Vista? In article <48a9db24$0$90269$14726298@news.sunsite.dk>, hasta la vista <hasta@lavista.org> wrote: > It follows doesn't it? > Trying to support Intel and PPC, OS X and Classic on PPC machines, Tiger > and Leopard both in same updates. > I'm sticking with Tiger as it works for me and I still haven't fully > explored it - so I'm wary about software updating everything because the > latest updates are primarily aimed at Leopard users. Apple tech support > forums, MacFixit and other websites, blogs and newsgroups have reported > increasing problems from users with older systems and conflicts with > older software. Sounds kind of like Windows and Vista? I'm sorry, but I've simply not notice any such trend. -- Alan Baker Vancouver, British Columbia <http://gallery.me.com/alangbaker/100008/DSCF0162/web.jpg> In article <alangbaker-6EDEE6...

how to get information from win32 console app
hi , &nbsp;&nbsp;&nbsp; I&nbsp;need to run &nbsp;a batch file from customer and get some information from win32 console app,how can i do it ? &nbsp; thanks for youre helps. &nbsp; &nbsp; sonic&nbsp; HI ,I have close it . so I close the discussion ...

Problem with Win32::Console and END block.
I want to set my dos window up with 80 cols and 100 lines, but when I do I break my END block. Here's an example... use strict; use warnings; $| =1; # use Win32::Console; # my $BUFFER = new Win32::Console(STD_OUTPUT_HANDLE); # $BUFFER->Size(80,100); for (1..5) {print "."; sleep 1} exit; END {print "\n\nPress Enter\n"; <STDIN>;} In the above form it works. BUT remove the comments from the first 2 or 3 (commented) lines, and the PRINT statement in the END block stops working. The <STDIN> still works, though. What am I doing wrong _this_ time? ;-) W2K,...

console window on Mac OS X
Dear Java Pros, I would like to implement a simple console window based on JTextPane (or similar) to emit Unix shell commands on Mac OS X. While I have found reasonable examples how to implement the GUI part, I have severe trouble in redirecting the input stream provided from the console window. I am using code like this: public ConsoleInThread(InputStream istream) { super(); is= istream; isr= new InputStreamReader(is); br= new BufferedReader(isr); } public void run() { try { while ((li...

Getting Handle for Main Window of an Application
Hi, It was suggested to me on the programmersheaven forum that this might be a good place to ask my question: I'm looking to ascertain which is the main window of a given application (in order to switch focus to it) without prior knowledge of the window class that it has. For example, if I consider the problem of switching to an instance of firefox, there are around a dozen windows (obtained from listing all the windows using EnumWindows) associated with the firefox process. Although I know that the correct window to switch to is that which has the class mozillaUIWindowClas...

Forwarding Output to Console (in windows programm)
Hey... I did create an windows application which an normal window... Also I did create an Console via "AllocConsole" for sending an retrieving status data to/from tghe user... Is there any possibility to forwad the outputhandle or the buffer to something like cout/cin to use those instead of ReadFile and WriteFile?... greetz, Inc Incubbus wrote: > I did create an windows application which an normal window... > Also I did create an Console via "AllocConsole" for sending an > retrieving status data to/from tghe user... > > Is there any p...

Better DOS than DOS, better Windows than Windows, better OS/2 than OS/2 :-)))
Hello, hereby I officially announce my entry into "eCS lusers" crowd :-) Installed 1.1 entry upgrade from Warp 4 on Saturday. Until now I was at Warp 4 FP15, and the days of fixed-patched-1996-oldtimer are gone. Although OS/2 base system in eCS 1.1 does not considerably differ from CP2, the value of added software (especially SDK 4.52) made my day. I got up-to-date OS/2 with SDK and other SW for cca 109 euro (thanks to my Warp 4). Just one notice about eCS: Should have happened earlier, in Warp 3 times. And just a drop of poison for you-know-who: I was able to run all my OS/2 software on this beast, therefore it must be OS/2. Cheers, Martin mmi@nautimail.com (MMI) wrote: <snip> And of course, I forgot enabled access to SWC SW :-) Cheers, Martin MMI wrote: > > mmi@nautimail.com (MMI) wrote: > > <snip> > > And of course, I forgot enabled access to SWC SW :-) That's a pretty good deal. How much will it cost you to access it next year? And the year after? How much will some other people pay for the same software? Dave In <a9aca7aa.0308040119.6d9ded08@posting.google.com>, on 08/04/03 at 02:19 AM, mmi@nautimail.com (MMI) said: >Hello, >hereby I officially announce my entry into "eCS lusers" crowd :-) >Installed 1.1 entry upgrade from Warp 4 on Saturday. Until now I was at >Warp 4 FP15, and the days of fixed-patched-1996-oldtimer are gone. >Although OS/2 base system in eCS 1.1 does not ...

Windows 7 and Eudora 7.1: problems, problems and problems.
Hi, 3 days ago I have replaced Win XP with Windows 7 and since first day I have problem with Eudora 7.1. My problems are when Eudora downloads emails. I have 6 account, Eudora downloads 3 accunts regularly, then gets stuck on 3� account for 1 minute or more and then it goes again regularly. Therefore I have deleted the 3� account then I have done the download. Eudora downloads 3 account regularly again then it gets stuck again. Always the same problem. Then ..... I have unistalled Eudora and deleted every trace on registry then I have installed it again but now I have the same problems. Perhaps have I to replace Eudora 7 with Eudora 8? I want to cry!!!! Help me please. Thanks a lot. PS. I have replaced beacause it is important for me new mailboxes with old mailboxes and I replaced Eudora.ini. Perhaps is it my problem? AroundTheWorld <AroundTheWorld@DELETEinterfree.it> wrote in news:s4usj5p0otqo5hlr30rsbnibj2t0uh3od1@4ax.com: > Hi, 3 days ago I have replaced Win XP with Windows 7 and since first > day I have problem with Eudora 7.1. > My problems are when Eudora downloads emails. > I have 6 account, Eudora downloads 3 accunts regularly, then gets > stuck on 3� account for 1 minute or more and then it goes again > regularly. > Therefore I have deleted the 3� account then I have done the download. > Eudora downloads 3 account regularly again then it gets stuck again. > Always the same problem. > Then ..... I h...

Problem with Pane y-axis handle (win32)
Perl 5.8.3, Tk 804.026, Win95b Having issues with Pane. Namely, if I start off with a Pane that has 'osow' scrollbar settings and it's not scrolled because it fits, and then the contents change to mandate scrolling, the handles don't act right. The x-axis handle appears and works. The y-axis, however, does not gain a handle even though the trough appears. If I use keyboard focus to get to that scrollbar and hit down-arrow once, it appears suddenly. I've tried a trick I had to use with a Scrolled ROText at one point, scrolling it with yview(moveto => 1) a...

how to get os.system () call to cooperate on Windows
I have a Python program that needs to copy files around. I could read and write which would be inefficient and would time-stamp the copy. The module "os" has lots of operating system functions, but none that copies files I could make out reading the doc twice. The function "os.system ('copy file_name directory_name')" turns out doesn't do anything except flashing a DOS command window for half a second. So my question is: How can one copy files on the OS level? This simple question would surely have been asked many times before. Not to impose on anyone&...

Problem displaying linux console from Windows 2k
Hi I am a newbie and I installed a headless server next to my Windows 2K computer in order to learn better about Linux. My problem is as follows. Everytime that I login to the server and execute "man" to look up the manual pages, I get some garbage characters on the screen. I have tried accessing my server using the following methods: 1. Cygwin environment using SSH 2. telnet from cmd.exe If I do "man bash" from the Cygwin shell inside my Win2K system, I get the following after NAME: bash - GNU Bourne-Again SHell If I conect to my headless server using ssh from the cygwin environment, I get the following: bash �^' GNU Bourne�??Again SHell If I do it by using telnet (the plain vanilla from windows2k) I get the following: bash ?�� GNU Bourne?��Again SHell And like those lines, there are several others with strange characters in between. I know that for some reason, ssh and telenet are not interpreting some escape sequence character. My question is the following. 1. How and Where can I find in Linux the format definition for the output, including what type of escape character they are using when somebody connects from outside the server. I am using redhat 8.0 2. what commands, if any do I have availabel under cygwin or ssh to properly interpret such an input? 3. what commands if any do I have available under Windows2k telnet to properly interpret sush an input? thanks, I apreciate whatever help ...

Problem in getting Damage report over root window
Hi all, I am attaching here my xorg log file, output of xinerama api's and co- ordinates of Root window.I could get damage report for rootwindow area of 1024 x 768. Why i couldn't get damage report for area of (1024 - 2048) * 762? (Second part of root window which is being virtualy enabled by dummy driver to memic the second video card display). What is the wrong i am doing here? Is there anything i am missing? This is the way i created damage report over root window. rootWin = RootWindow(g_Display,screen_num); xdamage = XDamageCreate(display, rootWin, XDamageRep...

Getting console window's hWnd
Hello I am writing a console app for Windows (running on Vista 32 bit at present) I would like to be able to resize the DOS window the program is running in, from within my code For this I would need to get that window's hWnd Can anyone advise how to do this? Many Thanks. Quentin Pope <qp19433@hotmail.NOSPAM.com> writes: > I am writing a console app for Windows (running on Vista 32 bit at > present) > > I would like to be able to resize the DOS window the program is running > in, from within my code > > For this I would need to get that window's hW...

Web resources about - Problem getting console window handle - comp.os.programmer.win32

Is–ought problem - Wikipedia, the free encyclopedia
The is–ought problem in meta-ethics as articulated by Scottish philosopher and historian David Hume (1711–76) is that many writers make claims ...

Establishing sleep patterns early in life key to avoiding future problems
Children have just the first five years of life to develop good sleeping habits before they are at risk of adjusting poorly to school and developing ...

Slater frustrated with shoulder problems
BILLY Slater is said to be “disappointed” and “frustrated” with the Melbourne Storm star set to undergo an arthroscope on his troublesome left ...

Establishing sleep patterns early in life key to avoiding future problems
Children have just the first five years of life to develop good sleeping habits before they are at risk of adjusting poorly to school and developing ...

SmartPot Problems: Marijuana And The Internet Of Things
What happens when you combine cannabis, whose laws are changing almost daily, with technologies that are constantly evolving as well?

Obama Wants SXSW to Help Solve America's Problems, Including Apple Standoff
President Obama asked a tech-savvy audience attending the first day of the South by Southwest Interactive Festival in Austin to help tackle the ...

NASTY: Bill Clinton's Disgusting Flatulence Problems Date Back to White House Years
It's not just Granny Catlady who stinks. It's also her husband : Clinton became so flatulent at one point during his presidency that his close ...

Weekend Reading: Andrew Gelman: The problems with p-values are not just with p-values
**Andrew Gelman**: [The problems with p-values are not just with p-values](http://andrewgelman.com/2016/03/07/29212/): >The American Statistical ...

Tesla has finally fixed a huge problem with one of its most important features
... heated-and-cooled option). In a car like the Model S that was otherwise pretty sensibly designed, its terrible cupholders were a glaring problem, ...

Apple's iPhone problem in one chart: Apple usually does worse than the market as a whole
... net adds of new phones are in decline , and the major portion of "growth" to be had is in replacing existing units. That's a particular problem ...

Resources last updated: 3/15/2016 10:20:46 AM