有关参考,请参阅此小程序的源代码EndPointController.exe: http ://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device- 在窗口-7 /
基本上,它是一个Visual Studio C ++程序,它使用printf函数将信息写入命令shell窗口。
下面是我在Windows 7 x64上运行程序的一个例子(使用上面提供的编译二进制代码):
C:UsersJamesDesktop>EndPointController.exe Audio Device 0: Speakers (High DeFinition Audio Device) Audio Device 1: AMD HDMI Output (AMD High DeFinition Audio Device) Audio Device 2: Digital Audio (S/PDIF) (High DeFinition Audio Device) Audio Device 3: Digital Audio (S/PDIF) (High DeFinition Audio Device) C:UsersJamesDesktop>
这完美的作品。 现在,我将尝试将输出redirect到一个文件:
使用PHP直接打印到networking打印机
Linux的C:容易&'漂亮'转储/结构的打印输出(如gdb) – 从源代码?
默认打印机设置被忽略
C:UsersJamesDesktop>EndPointController.exe > test.txt C:UsersJamesDesktop>type test.txt C:UsersJamesDesktop>
它没有工作; test.txt是空的。 这是一个权限问题?
C:UsersJamesDesktop>dir > test.txt C:UsersJamesDesktop>type test.txt Volume in drive C has no label. Volume Serial Number is 16EC-AE63 Directory of C:UsersJamesDesktop 04/20/2014 03:11 AM <DIR> . 04/20/2014 03:11 AM <DIR> .. 05/31/2011 06:16 PM 7,168 EndPointController.exe 04/20/2014 03:12 AM 0 test.txt 2 File(s) 7,168 bytes 3 Dir(s) 171,347,292,160 bytes free C:UsersJamesDesktop>
不,它似乎不是一个权限问题。 任何人都可以解释这个printf函数是如何绕过标准的redirect过程吗?
用batch file远程添加打印机; 0x32此操作不受支持
Windows服务打印PDF文件
通过SSH打印
在模块编程中使用printk日志级别
在Windows上打印源代码
添加fflush(stdout); 在return hr;之前return hr; 线为我修复它。
我尝试了一些其他的东西,比如将宽字符串转换为窄字符,并将其传递给printf,使用wprintf,编译为多字节,并将字符串转换为窄字符传递给printf,但只能手动刷新缓冲区。
我已经尝试从您包含的链接中下载项目文件,并运行已经构建并包含在“发布”文件夹中的可执行文件,并按预期工作。 我也在VC ++ 2013中重新构建了代码,并且按预期工作。
我怀疑操作员错误或系统问题 – 您的问题中的信息似乎并不建议操作员错误,但是; 你提供了证据证明这不是这种情况。
我运行了C:Users<userprofile>DocumentsVisual Studio 2013testRelease 。 Desktop是Windows中的一个“特殊”文件夹,可能会有一些影响,但我怀疑它。 无论哪种方式,我不认为这是一个编程问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。