LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass an array of clusters to DLL

I have to pass an array of clusters to a DLL and it doesn't work. The cluster has the following type:

typedef struct __USB_DEVICE_INFO
{
    GUID DeviceClass;
    LPWSTR szName;
    LPWSTR szLocation;
    LPWSTR szDeviceInstanceId;
} USB_DEVICE_INFO, *PUSB_DEVICE_INFO;


The DLL function has the following prototype:

USBENUMERATOR_API BOOL WINAPI EnumerateBus
(
    HANDLE p_hEnumerator,                // (IN) - Handle returned by CreateEnumerator
    PUSB_DEVICE_INFO* p_ppResultSet,    // (IN) - Pointer to an USB_DEVICE_INFO array
    PDWORD p_pdwLength                    // (IN) - Pointer to location where to store array length
);


In the DLL configuration window I selected 'Handles by Value' and 'Adapt to Type' for the parameters p_ppResultSet and p_PdwLength. The function works somehow, because for the p_pdwLength I get the right value returned (I have a sample c-test program using the same dll).
The problem is the array of clusters, the return-value is an empty cluster.
I pass an array with enough elements (15). The strings in the cluster are initialized with 50 characters. For the GUID I use an extended precicion number (GUID has to bi 128 bit).

Could the problem be, that the function is especting unicode strings (LPWSTR) instead of ASCII strings?

Thanks for any help!
Dave
0 Kudos
Message 1 of 6
(3,280 Views)
Hi Dave,

As far as I know, LabVIEW does not support unicode strings, that might be the source of your problem.


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 2 of 6
(3,273 Views)
Hi,
 
I searched our Knowledgebases, how to use unicode, DLL and LabVIEW.
 
Perhaps, this may be the solution:
 
Good Luck.
 
Alex
NI Switzerland
Message 3 of 6
(3,260 Views)
Nice Alex,

The link is perfect, but were to find the mentioned VI "ASCII to Unicode.vi" ?




Thanks for giving a link to the vi 😉

Message Edité par TiTou le 03-21-200611:48 AM


We have two ears and one mouth so that we can listen twice as much as we speak.

Epictetus

Antoine Chalons

0 Kudos
Message 4 of 6
(3,252 Views)
While seeking for that vi, Just test if adding one spare char (x00) to each character of your LV string solves the problem.  For  Latin1 character page in unicode this will do.

Good luck,
Sergey
0 Kudos
Message 5 of 6
(3,246 Views)
To say the truth, your way seems not right.

Look at these solutions
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DD8F56A4E034080020E74861&p_node=DZ52048&p_source=external
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3F05B56A4E034080020E74861&p_node=DZ52048&p_source=external
Sergey
0 Kudos
Message 6 of 6
(3,240 Views)