Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

c# with NI8451

Hello! I need to receive data from a device with an SPI interface through the NI-8451.
I am writing a program in c# (visual studio 2015) for reading data.
First question:
which *.dll is responsible for working with the NI8451 and where to get it. I have used ni845x.dll located in C:\Windows\SysWOW64. This is it?
Second is: to find ni845x.dll I use the type construct
using System;
using System.Runtime.InteropServices;
namespace Merge_data_files
{
    [StructLayout(LayoutKind.Sequential)]
    struct NiHandle
    {
//////
    }
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        [DllImport(@"Properties\Ni845x.dll", CharSet = CharSet.Unicode)]
        internal static extern int32 ni845xFindDevice(char* pFirstDevice, NiHandle* pFindDeviceHandle, uInt32* pNumberFound);
    }
}
 but Studio gives me errors about data types and structures unknown to c# (int32, char*, NiHandle)
How to fix the program or maybe there are some examples to work with NI8451 in c#?
0 Kudos
Message 1 of 2
(1,114 Views)

Dear Lexx,

 

Answer to the first question: Yes that is the right place.

 

Answer to the second question : Check this article : https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000YIIBCA4&l=en-US 

 

0 Kudos
Message 2 of 2
(922 Views)