[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problems with GetStdHandle(..) and ActiveDesktop !

Posted on 1998-09-22
6
Medium Priority
?
421 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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 recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

834 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