From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Argument for function not viewed able under VC++ by teststand editer

Solved!
Go to solution

Hello,

 

I have a question about the Teststand 4.0.

My dll is created by Visual C++ MFC, and exported following the format recommended by TestStand. Shown as below:

void __declspec(dllexport) __stdcall Function(struct IDispatch *seqContextDisp,bool &fStatus)

{...}

 

When trying to specify this function with teststand editer, only the type for the argument is viewed in the editer but the name for the argument is not avialable.

How can i get the name for the argument when i export a VC++ function?

 

BR

Bendy

0 Kudos
Message 1 of 25
(7,907 Views)

Bendy,

 

what version of Visual Studio do you use? Do you have Measurement Studio (version?)?

What additional settings do you use when building the DLL?

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 25
(7,856 Views)

hello, Norbert

 

I am using the Visual Studio 6.0, I don't have the Measurement Studio.

Only to add the <TestStation>/Bin to the included directory, no any other setting.

 

Thank you for your answer.

 

Bendy

0 Kudos
Message 3 of 25
(7,846 Views)

Bendy,

 

from the TestStand Reference Manual:

If a DLL contains export information or if a DLL file contains a type
library, the LabWindows/CVI and C/C++ DLL Adapters automatically
populate the Function control on the Module tab of the step with all the
function names exported from the DLL. In addition, when you select a
function in the DLL, the adapter queries the export information or the type
library for the parameter list information and displays it in the Parameter
Table control on the Module tab. If the adapter cannot determine parameter
information, you must enter the parameter information manually.

 

I think that you have a DLL where the export information is not part of the DLL (special compile option).

My next question is: Where did you get the "recommendation" regarding the function parameter?

I honestly don't see any issue with it, but the MFC-templates in TS 4.1.1 always use SequenceContext as type of the first parameter. I'd say this type is defined in the teapi.dll which is included in the template.

 

An additional excerp from the TestStand help:

If you are using Microsoft Visual C++ 6.0 with Service Pack 3 or later, you can use the #import compiler directive to automatically generate C++ classes for accessing the COM objects defined in a type library. To generate C++ classes for TestStand, you must first add the <TestStand>\Bin directory to the list of additional include directories in the Visual C++ project settings. Next, add the following directive at the top of the source file:

#import "teapi.dll"
 

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 25
(7,838 Views)

The names of the function parameters are not stored in the DLL when you compile with Visual C++ so TestStand cannot display them. The only way to get parameter names in TestStand for a function in a DLL is to use a type library.

 

Keep in mind that parameter names are cosmetic and don't affect the execution of the step.

 

Here is an article on how to create type libraries using LabWindows/CVI:  http://digital.ni.com/public.nsf/websearch/BCB57B5F7E0D292486256BFA005DAD92?OpenDocument

 

This old Microsoft article might help you get started using Visual C++ to build a type library:  http://support.microsoft.com/default.aspx?scid=kb;EN-US;189133

 

0 Kudos
Message 5 of 25
(7,827 Views)
Solution
Accepted by Bendy227

After replying to your message I did a little more research. This article discusses ways to automatically generate type libraries in a DLL for COM servers using C++ attributes available in Visual Studio .NET: MSDN. Although you probably don't want all the COM-related features, there is a section that discusses code modules that is applicable. I did a simple experiment with a MFC DLL and added the following code. TestStand was able to get the parameter names. You are limited in which data types you can use. For example, references (bool &fStatus) are not supported in type libraries.

 

[module(dll, name="MyDLL" ), idl_module(name="TestModule", dllname="" )];

 

extern "C" void __declspec(dllexport) __stdcall Function(struct IDispatch *seqContextDisp,bool *fStatus)
{
}

 

[idl_module(name="TestModule" ), entry("Function" )]
void __stdcall Function(struct IDispatch *seqContextDisp, bool *fStatus);

0 Kudos
Message 6 of 25
(7,823 Views)

hello Norbert B

 

I got the code template from the following path.

C:\Program Files\National Instruments\TestStand 4.0\CodeTemplates\NI\...

 

Maybe it should because the dll does not include the parameters information.

 

0 Kudos
Message 7 of 25
(7,807 Views)

hello Erik Crank

 

Thank you for your information. I get the point right now.

 

But according to your resource, i still can not make it successful to get the parameter name from TestStand.

Now it comes to be a problem how  to generate a type library in a DLL by Visual Studio 6.0.

 

Can you attach your sample for my reference?

0 Kudos
Message 8 of 25
(7,806 Views)

I am also in a similar situationI am able to create a DLL in VC++ 2008 that TestStand 4.1.1 can load with parameters listed, but the parameter names show up as "arg1", "arg2", etcThe types of each parameter is correct and I can execute the functions exported by my DLL, but it would be really helpful to have the parameter names show up in the sequence editor module settings pane when viewing / editing the stepHaving parameter names load via the DLL would make my sequence readability much easier / better for maintaining sequences.

 

It seems there's very little info (or I'm searching in the wrong place) on how to create a VC++ DLL that functions similarly to a CVI DLL when loaded in TestStandThe info on creating a CVI DLL is very thoroughI'm using existing C++ code and thus CVI isn't an option.

 

I have Measurement Studio Enterprise 8.6 installed, but I'm not using any special typesJust basic C++ types such as int, double, and string, so I'm not sure what it buys me.

Thanks!

0 Kudos
Message 9 of 25
(7,786 Views)

I've attached an example using Visual C++ 6.0. There are a few non-obvious steps I used to get this to work:

1. Create an IDL file and add it to the project. See my example for the format of the IDL file that works for TestStand.

2. Change the build settings for the IDL file to create the type library in the res folder (e.g. res\TypeLibTest.tlb).

3. Manually edit the resource file as a text file (e.g. TypeLibTest.rc) to add the following line to embed the type library in the DLL:

1 typelib res\\TypeLibTest.tlb

4. Use extern "C" and __declspec(dllexport) to export your functions from the DLL or put the names of the functions in the DEF file (e.g. TypeLibTest.def).

Message 10 of 25
(7,774 Views)