From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

资源文档分享区

如何在 LabVIEW 中得到 Windows API 的错误代码和信息

代码和文档

添加附件

how to get Windows API error code and message

本程序用于演示如何在 LabVIEW 中得到 Windows API 的错误代码和信息。详细说明请参考:http://ruanqizhen.spaces.live.com/blog/cns!5852D4F797C53FB6!2047.entry

我曾经发现调用 Windows API 函数是遇到的错误信息丢失的问题。在调用某一 Windows API 函数返回值为0时,表示有错误发生了。这时你可以调用 GetLastErr 和 FormatMessage 得到错误代码和信息。但是我经常遇到的问题是:前一个函数明明返回值为0,但是随后调用的 GetLastErr 函数却无法查到错误代码。 我想这一定是看上去两个函数是先后被 LabVIEW 调用的,但实际上 LabVIEW 在它们之间还要做两次线程切换才行。错误代码就是在线程切换的过程中被丢失了。解决这个问题的办法也是:把调用这三个函数的 CLN 和调用它们的 VI 全部设置为在界面线程下运行就可以了。

Other requirements:

Windows XP

NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可

评论
BetaCommunityCo
Member
Member
修改时间

coding example very limited

coding example very limited

it uses a pixel format description I never heard of, but OK it is an example.

The coding style is nice and I hope somebody can read the chinese explanation above

贡献者