Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Launch Test Panel Programatically

Hi,

Is there a means to launch a test panel on a device programatically, either
1) via a DAQmx API call, or
2) via a simple CreateProcess call to a NI provided executable with the device name as a command line parameter?

Thanks,
Nick
0 Kudos
Message 1 of 7
(4,382 Views)
I would like to know the answer to this as well.
0 Kudos
Message 2 of 7
(4,378 Views)

Hi Nick,

Thanks you for using the discussion forums. 

You can open a device’s Test Panel using the WinExec function.  This calls the test panel command line, which takes in a device name as a parameter and opens its associated test panel. 

Here is a link to this function call on MSDN

WinExec Function
http://msdn2.microsoft.com/en-us/library/ms687393(VS.85).aspx

The command for the Test Panel is: nidmfpan.exe /devid:“DeviceName”

Please note that this requires the Kernel32 library

Hope this helps

Chris_K

0 Kudos
Message 3 of 7
(4,354 Views)
Hi Nick,

If you go with with approach that Chris suggested, you will need to use P/Invoke to call into kernel32. This approach isn't bad, but a better approach is to use the Process.Start method that's part of the System.Diagnostics namespace. There are several overloads that you can use that take in the command line arguments that Chris mentioned.  I've just personally found it easier to use the Process class when dealing with calling command-line EXEs when possible.

Best Regards,
Jonathan N.
National Instruments
0 Kudos
Message 4 of 7
(4,351 Views)
Thanks, Chris and Jonathan.  It worked great.

For anyone else who happens upon this thread, here's my working code snippet.

            string path = Environment.SystemDirectory + @"\nidmfpan.exe";
            string DeviceName = "Dev1"; // or whatever your device is
            if (System.IO.File.Exists(path))
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName = path;
                proc.StartInfo.Arguments = "/devid:\"" + DeviceName + "\"";
                proc.Start();
            }
            else
            {
                MessageBox.Show("Cannot find your National Instruments installation");
            }

0 Kudos
Message 5 of 7
(4,329 Views)

Is the device name required?

Ie:  Can I do something like

             string path = Environment.SystemDirectory + @"\nidmfpan.exe";
            string DeviceName = "Dev1"; // or whatever your device is
            if (System.IO.File.Exists(path))
            {
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName = path;
                proc.StartInfo.Arguments = "/devid:\"" + DeviceName + "\"";
                proc.Start();
            }
            else
            {
                MessageBox.Show("Cannot find your National Instruments installation");
            }

0 Kudos
Message 6 of 7
(4,154 Views)
Yes.  Otherwise it is unclear which device you would like a test panel for.

string[] NIdevices = DaqSystem.Local.Devices;

will list all of your devices.

HTH,
Nick
0 Kudos
Message 7 of 7
(4,151 Views)