Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

What's the type of vistatus-VISA programming

Hi All
 
My custom has a dll which is based on NI-VISA to control their own instrument, I need to import this win32 dll in C#.net,
 
the prototype of a method in dll is   "ViStatus TXPRMGR_errorMessage (ViSession instrumentHandle,ViStatus statusCode,ViChar _VI_FAR message[]);  "
 
In my C# code, I wrote down like this  [DllImport("Targetdll.dll")]
                                                                public static extern type(type1 instrumentHandle, type2 statusCode, type3 message[]);
Please mind the red part, I don't know what type I should write down.
 
I'm not familiar with visatype.
 
Thanks very much.
 
Bestwishes
 
Rexxar.Ben
 
 
********************************
*The best Chinese farmer*
********************************
0 Kudos
Message 1 of 3
(5,234 Views)

Hi

 

My code as follow,but it does not work.

I am fresh with NI-VISA custom type.

  [DllImport("TXP_ResMgrDrv_32.dll")]
  public static extern Int32 TXPRMGR_errorMessage( Int32 instrumentHandle, Int32 statusCode, [MarshalAs(UnmanagedType.LPStr)] ref string message);

********************************
*The best Chinese farmer*
********************************
0 Kudos
Message 2 of 3
(5,233 Views)
This really has nothing to do with VISA, but try this (assuming stdcall calling convention)

[DllImport("TXP_ResMgrDrv_32.dll",CallingConvention=CallingConvention.StdCall)]
public static extern Int32 TXPRMGR_errorMessage (System.IntPtr Instrument_Handle, int Error_Code, System.Text.StringBuilder message);

If this doesnt work, you'll need to keep trying different configurations and make sure you understand how .NET handles interop.

Bilal Durrani
NI
0 Kudos
Message 3 of 3
(5,223 Views)