1.引入
private const Int32 STD_OUTPUT_HANDLE = -11;
[DllImport("Kernel32.dll")]
extern static Boolean SetStdHandle(Int32 nStdHandle, SafeHandleZeroOrMinusOneIsInvalid handle);
[DllImport("Kernel32.dll")]
extern static SafePipeHandle GetStdHandle(Int32 nStdHandle);
2.操作
//屏蔽dll中的输出 //2.1 获取输出句柄 var defaultHandle = GetStdHandle(STD_OUTPUT_HANDLE); //2.2 设置输出到匿名管道 SetStdHandle(STD_OUTPUT_HANDLE, new AnonymousPipeServerStream(PipeDirection.Out).SafePipeHandle); //2.3 调用第三方库(内含Console的输出) PaddleOCRSharp.PaddleOCREngine engine = new PaddleOCRSharp.PaddleOCREngine(config); //2.4 恢复 SetStdHandle(STD_OUTPUT_HANDLE,defaultHandle);
标签:STD,输出,Console,Int32,C#,DLL,HANDLE,OUTPUT From: https://www.cnblogs.com/chyshx/p/18055830