Solved

Problems with GetStdHandle(..) and ActiveDesktop !

Posted on 1998-09-22
6
390 Views
Last Modified: 2013-12-03
The function GetStdHandle(STD_OUTPUT_HANDLE) returns "0x00000000" in a "normal" windows-application, as it used to be.
On computers where ActiveDesktop is installed, the return value of this function is some strange handle. (like 0x12340...).
Any suggestions ?????????
0
Comment
Question by:thkoch
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Answers2000
ID: 1414672
What's the return from GetLastError after GetStdHandle ?
0
 

Author Comment

by:thkoch
ID: 1414673
The return from GetLastError is "0", in both cases.
By the way, the GetStdHandle-function returns everytime the same handle 0x12340042, even when I reboot the computer on which ActiveDektop is installed.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1414674
Answers2000 should read the docs: GetStdHandle() only sets GetLastError() when the return value is INVALID_HANDLE_VALUE.  INVALID_HANDLE_VALUE is not equal to 0x12340042.

B ekiM
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:mikeblas
ID: 1414675
Internally to the shell, the ShellExecute() API is being called to pass data to the newly started process. It tells the CreateProcess() API to ignore that data, but somehow the CreateProcess() API passes it along, anyway. The bottom line (if you ask me) is that it's a bug.

That mechanism works differently when desktop integration is installed. The handle value is meaningless to your application.

You can detect a valid handle by using the GetFileType() API in a __try/__except/__finally block to determine if the handle is valid before using it.

B ekiM

0
 

Author Comment

by:thkoch
ID: 1414676
The return from GetFileType is FILE_TYPE_UNKNOWN, so it seems to be a valid handle and I can even write to it.
But is there a kind of StdOutput on computers with AcitveDektop, or is it just a bug.
By the way, I have checked out several computers with ActiveDektop, and everytime I get 0x12340042.
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 100 total points
ID: 1414677
No. (Sorry; I assumed you knew how to use that API.) FILE_TYPE_UNKNOWN means (essentially) that it's not a valid handle type for standard handles; if someone were redirecting you, it would be a FILE_TYPE_DISK. If someone had spawned you and was reading your output, you would get FILE_TYPE_PIPE. If you're not being redirected, you get FILE_TYPE_CHAR.

Note that GetFileType() returns FILE_TYPE_UNKNOWN for INVALID_HANDLE_VALUE and for NULL, as well. The API returns FILE_TYPE_UNKNOWN for handles that aren't recognized by the system.

As I said, there's not a special standard output redirection with ActiveDesktop. As I said, it's just a bug.

B ekiM

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now