Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Problems with GetStdHandle(..) and ActiveDesktop !

Posted on 1998-09-22
6
Medium Priority
?
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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 400 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

647 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