Bookmark:Win32/WinCE Standard I/O Redirection in C program

Windows platform

 Creating a Child Process with Redirected Input and Output

Key point: SetStdHandle(), GetStdHandle 

Windows Embedded CE Platform 

On WinCE 4.2 or later use both GetStdioPathW() & SetStdioPathW()

Headed File: #include <Pkfuncs.h>

TargetLib : Coredll.lib

PocketPC: not have a standard console, kernel still support the function,

but Symbolictools provide a PocketPC console

http://www.symbolictools.de/public/pocketconsole/developers/

http://www.symbolictools.de/public/pocketconsole/developers/articles/console_internals.htm

 

update:

to read "fopen.c", "stdioinit.c(implement stdlib)", "kmisc.c(Implement GetStdioPath/SetStdioPath)" under private directory can find out a _wfreopen() function in CRT(C RunRime library) to redirection stdin/stdin/stderr

Technorati tags: , ,

// testIOredir.cpp : Defines the entry point for the console application.
// The demo program can redirection stdout stream to "\.test.txt" file
// so can use the feature to implement a simple log mech.
// Test passed on Pocket2003 Emulator

#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>

int _tmain(int argc, _TCHAR* argv[])
{

    FILE* fp;
    fp = _tfreopen(L"test.txt", L"w+", stdout);
    if (fp == NULL)
        printf("test");
  

    printf("The program just to test I/O redirectionrn");
    return 0;
}

 

update:

ref : http://msdn2.microsoft.com/en-us/library/wk2h68td(VS.71).aspx , C Standard function

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s

%d 位部落客按了讚: