Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxGetSysDevNames in Visual Studio 2005 C++

As a new C++ user coming from Delphi, Im struggling with the above function.

I'm trying to develop a program in VSC++ where I press a button on a form and the Device name (Dev1, Dev2, etc) is displayed in a textBox. I am having no success in getting the data back from DAQmxGetSysDevNames.

The code below, the equivalent of which does work in Delphi, should return Dev1, Dev2 in the data. I get nothing, presumably because the definition of data in the function isn't correct. Where am I going wrong?

Thanks for any help.

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {

uInt32 buffersize = 1024;
char *data;
Int32 daqstatus = DAQmxGetSysDevNames(data, buffersize);
String ^systemstring = gcnew String(data);
textBox1->Text = systemstring;

}
0 Kudos
Message 1 of 3
(5,025 Views)

Greetings Andy

It would be simpler to use the DAQmx .NET class if you are using managed C++. You would need to marshall unmanaged string arrays to managed ones.

The DAQmx .NET API is included with the DAQmx driver. It was written for .NET 1.1, but it works with .NET 2.0 as well.
To use it, you would need to make sure you install .NET support when you installed DAQmx. You can make sure of this if you rerun the driver installer from add/remove programs.

Once you install it, it will install the required assemblies under C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Assemblies\Current

Even though the path says Measurement Studio, you are not required to have it to install the DAQmx .NET API.

The required assemblies are NationalInstruments.Common.dll and NationalInstruments.DAQmx.dll. Once you add these assembly references to the VC++ project from the folder I mentioned above, add the namespace for it to your app as follows

using namespace NationalInstruments::DAQmx;

You can then query DAQmx for the device names

array<System::String^>^ devarray = DaqSystem::Local->Devices;
textBox1->Text = devarray[0];

If you only have VS 2005 installed, you will not be able to view the help files for the DAQmx .NET API, since they were designed to integrate with VS 2003 and the help system for VS 2005 is completely different. 

We are working to release native .NET 2.0 DAQmx libraries soon. So you wont need to worry about needing to download a third party help viewer. Not to mention the library will be targetted specifically for .NET 2.0.

On a side note, as an ex-Delphi user, I would have figured C# would have been the preferred language of choice. I'm curious as to why you prefer managed C++ over C#.

I hope this helps. Let me know if you have any other questions.

Bilal Durrani
NI
Message 2 of 3
(5,015 Views)
Hi Bilal

thanks for the reply. I may stick with Delphi for the time being... at least I have a fair idea of what I'm doing.

Why C++ and not C#? I'm not up to speed at the moment with the differences between the various incarnations of C so I didn't know that C# was more Delphi like than C++.

I'll look into this a bit more now.


Thanks

Andy
0 Kudos
Message 3 of 3
(5,011 Views)