LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using wnaspi32.dll with LabVIEW

 
My boss wants me to port a console application which displays information about the hard drives connected to the computer.  The console application was written in C and he wants it ported to LabVIEW.  It uses wnaspi32.dll.
 
Unfortunately the dll has a single entry point with a union of different structures as its only argument.  That is, the function takes in a structure, whose size and "other members" are dependent on the first four members of the structure (kinda like printf, but not using a varargs form, rather the first four structure members contain information about how succeeding bytes in the structure are, well, structured).
 
So far, we've tried:
1. Using a cluster as the input to the function.  The VI stalls for a long time, and then an error from "memory.c", saying that memory has been corrupted (prolly the GC, the dll might have corrupted the metadata, what's LV's memory management scheme anyway?  Looks suspiciously like compile/run-time GC.)
2. Using an array of bytes as the input to the function.  Same result as above.
3. Using a simple wrapper dll which does a LoadLibrary call on wnaspi32.dll.  LabView displays a warning saying that an error may have occured in the external DLL, recommending that files be saved in another location, but continues running anyway.
 
We haven't tried yet:
1. Unloading the wnaspi32.dll library
2. Using a wrapper dll with an implicit loading of wnaspi32.dll (i.e. #include <wnaspi32.h>).
3. Give up on LabVIEW.
 
My bets are mostly on writing a complete wrapper dll, but then I'd still be using C - is LabVIEW really that crippled?
 
I've found two topics so far about this:
  but they seem to lack details.
(BTW I found them on Google - the search function here never even saw them)
 
 
0 Kudos
Message 1 of 3
(2,581 Views)
As an update, we've found the problem in using LoadLibrary above - it was actually a calling-convention problem (was using C call in the Call Library function, should have been STDCALL).
Anyway, we're now doing a wrapper DLL for this DLL. Does anyone have any suggestions/comments?
0 Kudos
Message 2 of 3
(2,574 Views)
[sheesh]Whee I'm talking to myself again![/sheesh]
I've started building a wrapper DLL in C++ for this and it now works.
Basically, here is one suggestion in writing this in C++:
1. Use the (type)& syntax to simulate multiple return values in LabVIEW:
void __stdcall LVGetASPI32SupportInfo(BYTE& status, BYTE& numHosts){
  DWORD rval=GetASPI32SupportInfo();
  status=(BYTE)rval>>8;
  numHosts=(BYTE)rval;}
In LabVIEW, (type)& syntaxes are equivalent to "Reference To Value".

Message Edited by amkg on 07-28-2006 02:33 AM

0 Kudos
Message 3 of 3
(2,563 Views)