NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify environment when using custom interface

Solved!
Go to solution

Hi

this thread is almost dealing with my task.

https://forums.ni.com/t5/NI-TestStand/How-to-specify-environment-when-using-custom-OI/m-p/3617452

 

BTW my task is quite different. I am NOT using the ApplicationManager. So commandline will not work at all.

 

I am initializing the engine in old school:

 

HRESULT res = m_engine.CreateInstance("TestStand.Engine");

 

is there any change to work with environments?

 

Regards

 

Juergen

 

 

 

 

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 1 of 5
(3,961 Views)

Hey Juergen,

 

It looks like you can call EngineInitializationSettings.SetEnvironmentPath() before creating the engine. The EngineInitializationSettings class is new to 2016.

 

I haven't had a chance to try it... so let me know if that works!

 

-Trent

https://www.linkedin.com/in/trentweaver
Message 2 of 5
(3,930 Views)

Hi Trent,

 

Thanks for this useful information.

Now I have the problem to invoke that class.

under TS2016 there is no CLSID.

#import "C:\\Program Files (x86)\\National Instruments\\TestStand 2016\Bin\\teapi.dll"

(at least did not found one)

How do you create that instance.

IEngineInitializationSettingsPtr engineInitSettings;

HRESULT res = engineInitSettings.CreateInstance(??????);

Or is  it provided by another interface?

 

Best regards

 

Juergen

 

 

 

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 3 of 5
(3,916 Views)
Solution
Accepted by j_dodek

You should be able to get it with __uuidof(TS::EngineInitializationSettings).

 

Here's a crude snippet that i used to test:

Spoiler
#import "teapi.dll"
#include <iostream>

using namespace TS;

int main() {
CoInitialize(NULL);
IEngineInitializationSettingsPtr engineInitSettings;
IEnginePtr enginePtr;
HRESULT HR;

//Set Environment
HR = engineInitSettings.CreateInstance(__uuidof(EngineInitializationSettings));
engineInitSettings->SetEnvironmentPath("C:\\Users\\Public\\Documents\\National Instruments\\Custom\\myCustomEnv.tsenv");

//Get Environment
HR = enginePtr.CreateInstance(__uuidof(Engine));
std::cout << enginePtr->GetEnvironmentPath();
return 0;
}

I also have the include path added to my project settings instead of specifying it manually:

Capture4.PNG

 

-Trent

https://www.linkedin.com/in/trentweaver
Message 4 of 5
(3,909 Views)

Hi Trent,

 

awesome!

More than a decade I was always using the CLSID.

and sometimes you would not see the simple life.

 

Thanks for opening my eyes

 

Juergen

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 5 of 5
(3,895 Views)