adobeair NativeProcess与c++ Windows(非控制台)应用程序的通信

Adobe Air NativeProcess communication with C++ Windows (non-console) application

本文关键字:控制台 应用程序 通信 NativeProcess c++ Windows adobeair      更新时间:2023-10-16

如何在非控制台c++应用程序中实现侦听器以侦听来自adobeair的标准输入?
在c#控制台应用程序中,它看起来像:

namespace HelloNativeProcess
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Stream stdin = Console.OpenStandardInput())
            using (Stream stdout = Console.OpenStandardOutput())
            {
                byte[] buffer = new byte[2048];
                int bytes;
                while ((bytes = stdin.Read(buffer, 0, buffer.Length)) > 0)
                {
                    stdout.Write(buffer, 0, bytes);
                }
            }
        }
    }
}

我需要一个例子在c++中与APIENTRY winMain() -启动函数。谢谢。

找到答案了。谢谢Pete。

HANDLE thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateAppThread, (LPVOID)NULL, 0, NULL);
线程函数

 BOOL CreateAppThread()
    {       
        hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
        hStdin = GetStdHandle(STD_INPUT_HANDLE);
        CHAR buffer [2048];
        DWORD bytes_read, bytes_written;
            while(ReadFile( hStdin, buffer, sizeof(buffer), &bytes_read, NULL))
            {   
                WriteFile(hStdout, buffer, sizeof(buffer), &bytes_written, NULL);
            }       
            return TRUE;    
    }