06-17-2010 08:16 AM
We develop instrument and their driver using ni-VISA. all our driver are DLL Based
and we call them in VB 6 : ( for example)
call intrumentSomething(Visa Instrument Handle, someValu)
in VB6 we use to create a visa session with viOpenDefaultRM this would give us a session unmber,
then with this session number and the PXI or GPIB instrument ViOpen would give us an InstrumentHandle Number
this instrument number would be use for our own Driver and for the like of viOut16( InstrumentHandle,spacebar,ofset,data)
In Vb .net I found out to do a viout by NationalInstruments.VisaNS.RegisterBasedSession
then rbSession.Out16(spacebar,ofset,data)
this works fine no problem it is actualy quite nite.
Question How Do I retreive an insrument handle from .net for my already written drivers?
many thanks.
Solved! Go to Solution.
06-21-2010 02:56 AM
Hi Lambda,
Just to clarify, you have a driver written in VB6 and you wish to retrieve the instrument handle using VB.net?
Regards,
Jas.W
06-21-2010 03:53 AM
Hi
DLL are win32 libraries written in C and they all use internally Vi calls like Viout16 or ViIn16 or Vi MoveIn all of then require the module Visa instrument handle as their first argument.
My customer may use VB6 VB.net C or labview to write their own test application that use our PXI or GPIB instruments. I have not figured out yet how retrieve this instrument handle from the VisaNS class. ( if it is possible.)
thanks
06-25-2010 03:46 AM
FOUND IT...
This I think is the LINK between VisaNS and Visa32.dll
ALL VISA32 (old calls) use a ViSession number UInt32 in type.
With VisaNS the session is a CLASS but the Handle CAN be retreived:
Like this:
Imports NationalInstruments.VisaNS
Public MySession As PxiSession ' if you want PXI
Public MyOldViSession as UInt32
MySession = CType(ResourceManager.GetLocalManager.Open(PXI::9::INSTR), PxiSession)
MyOldViSession = MySession.Handle
MyOldViSession is the instrument driver handle you need to act in the old ViInt16 or viGetAttribute of the old Visa32.dll
Note that this property does not pup up in vb.net list of available properties for this class you have to manually type it.
But it is listed in documentation.
when you are finished: MySession.Dispose()
Let me know if this help...