Re: Porting app using GetStdHandle
From: John Spaith [MS] (jspaith_at_ONLINE.microsoft.com)
Date: 09/14/04
- Next message: Almon B. Strowger: "Re: PPC modem"
- Previous message: darrin Garrett: "Re: PPC modem"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 13 Sep 2004 18:10:11 -0700
I believe that in general if stdin is redirected to your application, then
when your app calls scanf() or whatever then the c-runtime should just make
the right data show up. I don't quite know how redirection is setup on
PocketPC's, since PocketPC doesn't ship cmd.exe, which is the only app I
know that would ever change stdin based on file redirection. So this may be
an unneeded feature on CE.
Assuming you need to do this after all, looking at stdlib.h, there are these
definitions:
// Std handle defns
#define stdin _getstdfilex(0)
#define stdout _getstdfilex(1)
#define stderr _getstdfilex(2)
_getstdfilex is itself a function declared as:
_CRTIMP FILE* __cdecl _getstdfilex(int);
So you may be able to call "FILE *f = stdin;" and then use the "UNIXy"
filesys API's that take FILE* as an argument, like fread().
If this fails -- CE has a function named GetStdioPathW(). This won't give
you a handle, but will give you the prefix of the driver that is currently
giving your app STDIN - i.e. "CON3:" for console based apps or "TEL5:" for
telnet server. You may be able to take this prefix string and call
CreateFile() on it, then call ReadFile() on the returned handle. Emphasis
on "may" since I'm not sure if this will work or not.
-- John Spaith Software Design Engineer, Windows CE Microsoft Corporation Check out the new CE Networking Team Blog at http://blogs.msdn.com/cenet/. This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use. © 2003 Microsoft Corporation. All rights reserved. "Thomas Canter" <zigky48v3dehqi89w6az9opc7d6yfpxw@earthlink.net> wrote in message news:Cel1d.304$mb6.1@newsread3.news.atl.earthlink.net... >I would like to port a C++ application, and I am checking to see if there >is > a one-to-one replacement for the GetStdHandle function call. > > This functionality is not critical to the application, but I want to make > sure that I don't miss an opportunity to include this functionality > (reading > from a redirected STDINPUT) on my app. > > Thanks, > Tom > >
- Next message: Almon B. Strowger: "Re: PPC modem"
- Previous message: darrin Garrett: "Re: PPC modem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|