Error -180 When Using FileSelectPopupEx in LabWindows™/CVI™

Updated May 31, 2024

Reported In

Software

  • LabWindows/CVI

Issue Details

I'm trying to display a file dialog to a user in LabWindows™/CVI™.  I found a built in function for this, FileSelectPopupEx, but I get an error when I try to call it.  Why am I seeing Error -180 when I use this function?

Solution

The FileSelectPopupEx function use a specific threading technique, which if combined with other functions which require multi-threading, such as some ActiveX functions, this error will appear. 
 

To ensure that these functions are using the correct type of threading you must include the following line of code at the start of your function, specifying the threading method before any other function does.

CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED)

If you are using TestStand, you need to add

CA_InitActiveXThreadStyleForCurrentThread (0, COINIT_APARTMENTTHREADED)

before calling

TS_NewEngine()

Once this line is included, continue the code as normal and you should not see this error.

Additional Information

FileSelectPopup is the precessor command from FileSelectPopupEx, use FileSelectPopupEx to display a Windows Vista and later style dialog box.