简体   繁体   English

ReadFile()输出到WinAPI编辑对话框

[英]ReadFile() Output to WinAPI edit Dialog

Ok, let's see if this all makes sense. 好吧,让我们看看这一切是否有意义。 Today, as I began working on a small project, I ran into an error I can't seem to get over. 今天,当我开始研究一个小项目时,我遇到了一个我似乎无法克服的错误。 The function of the program I am working on is to read data from a pipe (which is the output of another program) and update an HWND ("edit") control dialog using WinAPI. 我正在处理的程序的功能是从管道(这是另一个程序的输出)读取数据并使用WinAPI更新HWND(“编辑”)控制对话框。 Now, I've been successful at updating the dialog: sort of. 现在,我已经成功更新了对话框:有点儿。 If I send the character buffer from the ::ReadFile() function to the dialog, I get the proper output but with a ton of extra characters I don't want. 如果我将:: ReadFile()函数中的字符缓冲区发送到对话框,我会得到正确的输出,但是我不想要大量的额外字符。 So how can I simply strip it to the output I'm looking for, or is there a better way to accomplish what I'm attempting? 那么我怎样才能简单地将其剥离到我正在寻找的输出中,或者是否有更好的方法来完成我正在尝试的内容? Perhaps take the output and WriteFile(); 也许取输出和WriteFile(); or something similar to decipherable text? 或类似于可辨认文本的东西?

Here is what's happening: 这是发生了什么:

some output...'Hola Mondo' means... Hello word!ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ$ 一些输出...'Hola Mondo'的意思是......你好!我们的颜色是什么颜色的!颜色,颜色,颜色,颜色,颜色,颜色,颜色,颜色,颜色,颜色,颜色......

Here is what I want to happen: 这就是我想要发生的事情:

some output...'Hola Mondo' means... 一些输出...'Hola Mondo'意味着......

Hello word! 你好一句话!

Thanks so much for your help! 非常感谢你的帮助!

Regards, 问候,
Dennis M. 丹尼斯·M

检查ReadFile的“字节读取”输出参数,以便知道字符串的长度,然后在该偏移处放置一个终止的NUL(“\\ 0”)字符。

Most likely you're not 0-terminating your buffer before passing it to the text updating function. 在将缓冲区传递给文本更新函数之前,很可能不会将缓冲区终止。

Check the 'Example: Open a File for Reading' from here . 这里检查'示例:打开要读取的文件'。

It looks like you just need to add a '\\0' termination character to the string you're passing to the edit control. 看起来你只需要在传递给编辑控件的字符串中添加一个'\\ 0'终止字符。

But your question should show the code including the ReadFile() and where you pass the data to the edit control so someone can say for sure (and give a better suggestion). 但是您的问题应该显示包含ReadFile()的代码以及将数据传递给编辑控件的位置,以便有人可以肯定地说(并提供更好的建议)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM