EDN Admin
Well-known member
Hello,
I am currently adding USB capability to my hardware application and am having a little trouble using the manufacturer provided .dll in my vb.net program.
Here is a description of theVisual C++ 6.0 API function which i am trying to call from my vb.net program:
<p align="left
<span style="font-size:small
<p align="left Funtion name: CP210x_GetProductString
<span style="font-size:x-small
<p align="justify <span style="font-family:Courier New,Courier New; font-size:x-small <span style="font-family:Courier New,Courier New; font-size:x-small CP210x_GetProductString(DWORD
<span style="font-family:Verdana dwDeviceNum, LPVOID <span style="font-family:Verdana
lpvDeviceString, DWORD <span style="font-family:Verdana dwFlags)
<span style="font-size:x-small
CP210x_GetProductString(
DWORD dwDeviceNum,
LPVOID lpvDeviceString,
DWORD dwFlags
);
<span style="font-size:x-small
// Type definitions
typedef char CP210x_DEVICE_STRING[CP210x_MAX_DEVICE_STRLEN];
<span style="font-size:x-small
// Buffer size limits
#define CP210x_MAX_DEVICE_STRLEN 256
<font size="2
<p align="justify Description:
</font>
<p align="justify
<span style="font-size:x-small <span style="font-size:x-small <font size="2
1.
</font>
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small DeviceNumâIndex of the device for which the product description string, serial number or full path is desired.
<font size="2
<p align="justify 2.
</font>
<p align="justify <span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small DeviceStringâVariable of type
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small CP210x_DEVICE_STRING
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small returning the NULL terminated serial number, device description or full path string.
<span style="font-size:x-small <font size="2
3.
</font>
<span style="font-family:Arial; font-size:x-small I am able to pass the the dwDeviceNum and dwFlag using the following decleration in my vb.net program, but i am unable to return the DeviceString.
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <font size="2" color="#0000ff <font size="2" color="#0000ff
Declare
</font></font><font size="2" color="#0000ff
</font>
<span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Auto<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Sub<span style="font-size:x-small CP210x_GetProductString
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Lib<span style="font-size:x-small
<span style="color:#a31515; font-size:x-small <span style="color:#a31515; font-size:x-small "CP210xManufacturing.dll"<span style="font-size:x-small (<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
dwDeviceNum <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Integer<span style="font-size:x-small ,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByRef<span style="font-size:x-small DeviceString
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small (),
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small dwFlags
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small )
<span style="font-size:x-small I have tried declaring my DeviceString as a few different data type, but an unable to retreive any data. Can anyone point me in the rite direction? I have never had to mix code from Visial C++ in my VB.net application and
am a little lost.
<span style="font-size:x-small Thank You
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small OptionsâFlag that determines if
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small DeviceString
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small contains the product description, serial number or full path string. <span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small This
function returns a null terminated serial number (S/N) string, product description string or full path string for the device specified by an index passed in the DeviceNum parameter. The index of the first device is 0 and the index of the last device is the
value (NumDevices) returned by CP210x_GetNumDevices() - 1.
View the full article
I am currently adding USB capability to my hardware application and am having a little trouble using the manufacturer provided .dll in my vb.net program.
Here is a description of theVisual C++ 6.0 API function which i am trying to call from my vb.net program:
<p align="left
<span style="font-size:small
<p align="left Funtion name: CP210x_GetProductString
<span style="font-size:x-small
<p align="justify <span style="font-family:Courier New,Courier New; font-size:x-small <span style="font-family:Courier New,Courier New; font-size:x-small CP210x_GetProductString(DWORD
<span style="font-family:Verdana dwDeviceNum, LPVOID <span style="font-family:Verdana
lpvDeviceString, DWORD <span style="font-family:Verdana dwFlags)
<span style="font-size:x-small
CP210x_GetProductString(
DWORD dwDeviceNum,
LPVOID lpvDeviceString,
DWORD dwFlags
);
<span style="font-size:x-small
// Type definitions
typedef char CP210x_DEVICE_STRING[CP210x_MAX_DEVICE_STRLEN];
<span style="font-size:x-small
// Buffer size limits
#define CP210x_MAX_DEVICE_STRLEN 256
<font size="2
<p align="justify Description:
</font>
<p align="justify
<span style="font-size:x-small <span style="font-size:x-small <font size="2
1.
</font>
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small DeviceNumâIndex of the device for which the product description string, serial number or full path is desired.
<font size="2
<p align="justify 2.
</font>
<p align="justify <span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small DeviceStringâVariable of type
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small CP210x_DEVICE_STRING
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small returning the NULL terminated serial number, device description or full path string.
<span style="font-size:x-small <font size="2
3.
</font>
<span style="font-family:Arial; font-size:x-small I am able to pass the the dwDeviceNum and dwFlag using the following decleration in my vb.net program, but i am unable to return the DeviceString.
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <font size="2" color="#0000ff <font size="2" color="#0000ff
Declare
</font></font><font size="2" color="#0000ff
</font>
<span style="font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Auto<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Sub<span style="font-size:x-small CP210x_GetProductString
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Lib<span style="font-size:x-small
<span style="color:#a31515; font-size:x-small <span style="color:#a31515; font-size:x-small "CP210xManufacturing.dll"<span style="font-size:x-small (<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
dwDeviceNum <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Integer<span style="font-size:x-small ,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByRef<span style="font-size:x-small DeviceString
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small (),
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small dwFlags
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small )
<span style="font-size:x-small I have tried declaring my DeviceString as a few different data type, but an unable to retreive any data. Can anyone point me in the rite direction? I have never had to mix code from Visial C++ in my VB.net application and
am a little lost.
<span style="font-size:x-small Thank You
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small OptionsâFlag that determines if
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small DeviceString
<span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small contains the product description, serial number or full path string. <span style="font-family:Arial,Arial; font-size:x-small <span style="font-family:Arial,Arial; font-size:x-small This
function returns a null terminated serial number (S/N) string, product description string or full path string for the device specified by an index passed in the DeviceNum parameter. The index of the first device is 0 and the index of the last device is the
value (NumDevices) returned by CP210x_GetNumDevices() - 1.
View the full article