Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to access IVI-ConfigStore

Hi !

I'm trying to access the IVI ConfigStore to get the
IOResourceDescriptor for a particular session-name.

The VC++ code looks like this:

HRESULT hr;
IIviConfigStorePtr iviConfigStore;
hr = iviConfigStore.CreateInstance(__uuidof(IviConfigStore));
if (!SUCCEEDED(hr)) {
// do anything
}

hr = iviConfigStore->Deserialize(iviConfigStore->GetMasterLocation());
if (!SUCCEEDED(hr)) {
// do anything
}

Creating the instance fails with errorcode hr = 0x80010106
(Cannot change thread mode after it is set.).

The threading-model I use is set via CoInitializeEx:

CoInitializeEx (NULL, COINIT_MULTITHREADED);


Maybe anybody has an idea of what I'm doing wrong.

Thank you very much and my best regards,

Michael Mzik
0 Kudos
Message 1 of 5
(4,639 Views)
Are you calling this this code from the main thread in an MFC Windows (as opposed to console or service) application?
 
In internal application startup code, MFC call OleInitialize on the application main thread. OleInitialize initializes the thread as apartment threaded. Your call to CoInitialize attempts to initialize the thread as multithreaded. COM does not permit you to change the threading model of the thread without first unitializing it.
 
If this is the problem, you should be able to fix it just by removing your call CoInitializeEx.
 
 
0 Kudos
Message 2 of 5
(4,635 Views)

But, if CoInitializeEx() call with COINIT_MULTITHREADED is the problem, that error code must be returned from CoInitializeEx, not from CreateInstance(). I tried both thread types using CoInitialize() and CoInitializeEx()/MULTI.  Then, of course the Apartment/Mult mixture of  CoInitializeEx() was not allowed however, both cases were succeeded for CreateInstance() call (HRESULT == S_OK).  Therefore I could not find any cases that the CreateInstance() or CoCreateInstance() function returned the 0x80010106. 

The IVI Config Store DLL is marked as ThreadingModel=Apartment in the system registry at CLSID {EBC90D48-10D2-4E40-AE35-C993E127B815}. I believe the Config Store object can be created with COINIT_MULTITHREADED condition, once CoInitializeEx() has succeeded.

0 Kudos
Message 3 of 5
(4,629 Views)
Thank you very much for the replies !

I tried both alternatives:

CoInitialize (NULL);
and
CoInitializeEx (NULL, COINIT_MULTITHREADED);

The problem with CoInitialize(NULL) is,
that for some reason after clsoing a driver-instance and
releasing it, a second call to CreateDriver() or CreateSession() fails with hr = 0x800401fd
(Object is not connected to server).

With CoInitializeEx(..) this is no problem, but I cant
get access to the ConfigStore as mentioned my starting post.

I updated my OS (Win 2000) with latest fixes/packs, etc..

I have no idea..
0 Kudos
Message 4 of 5
(4,625 Views)

I tried CoInitializeEx (NULL, COINIT_MULTITHREADED) call in a test MFC app, but no problem regarding IVI Config Server was generated.  Where is your CoInitializeEx() call placed in your app? My test case was at the very beginning of CMyApp::InitInstance(), allowing CoInitializeEx(multi) to return S_OK (not S_FALSE).

Also, is your IVI Shared Components the latest version? If not, try to update it.

0 Kudos
Message 5 of 5
(4,605 Views)