CVI 调用ACtiveX控件出现错误
Posted xihong2014
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CVI 调用ACtiveX控件出现错误相关的知识,希望对你有一定的参考价值。
利用CVI 做工程,三级窗体包含日期activeX控件,在win10下运行报如下错误。
后在main.c 中加上这个
if (InitCVIRTE (0, argv, 0) == 0)
return -1;
CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED );
这样解决问题。
Q:ActiveX controls cannot be created in a thread whose concurrency model is multithread apartment (MTA)
A:The fix to this issue is to call CA_InitActiveXThreadStyleForCurrentThread prior to calling NiScope_Init. The explanation of this is that the ActiveX controls need to run with the apartment-threading-model (STA). When the CVI run-time encounters an ActiveX control it will initialize the thread to STA. What is happening is that NiScope_Init is probably initializing this to a multi-thread-apartment(MTA) first, so it is running into a conflict when the CVI run-time tries to run it on STA since its already initialized on MTA
以上是关于CVI 调用ACtiveX控件出现错误的主要内容,如果未能解决你的问题,请参考以下文章