Solved

Problems with GetStdHandle(..) and ActiveDesktop !

Posted on 1998-09-22
6
403 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

Suggested Solutions

Title # Comments Views Activity
Windows Mobile 6.5 device Apache Flex 3 49
Windows Installer 4 76
Messagebox for a Web Site Application 4 82
Strange - Deleted Resource Info appears in Azure Portal 6 96
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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