Solved

Problems with GetStdHandle(..) and ActiveDesktop !

Posted on 1998-09-22
6
406 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

724 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