473,382 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

need help to call API

hi all !!!
i need to call this API :
FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD
Flags)

i have a sample code in C++ that work fine...
FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD Flags)
FT_STATUS ftStatus;
DWORD numDevs;

ftStatus = ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY);
char Buf[64];
ftStatus = ListDevices((PVOID)numDevs, buffer,

FT_LIST_BY_INDEX|FT_OPEN_BY_DESCRIPTION);

but i don't know how i can convert it on VB.NET

thank a lot !
Nov 20 '05 #1
5 4210
I'm assuming FT_STATUS is 32-bit number. Another thing is bothering me -
the first param is a DWORD. You are passing its address in the first call
(which I assume causes the function to return the number), but then you are
casting the number to a pointer in the second call?? That doesn't seem
right. I will assume you will always need to pass an address. I'm also
assuming the buffer is an ASCII string. Otherwise, you'll want to change
that to a Byte array. Strange that you declare Buf[64] as a Char array, but
then use a non-existant buffer variable. That leaves my interpretation of
the second paramater in a little bit of a mystery. I'm assuming at the
moment that buffer is the address of Buf.

Declare ANSI Function FT_ListDevices(ByRef pArg1 As Integer, ByVal pArg2 As
String, ByVal Flags As Integer) As Integer

You will need to get the numeric values for the 3rd parameter and create
constants for them. Also, in the first call, pass String.Empty to the second
parameter (which will translate to NULL).

PS: All C(++) programers that assign PVOID or *void to variables and
parameters are going to the same hell as VB programers who don't declare
their variables.

-Rob Teixeira [MVP]

"Eric BOUXIROT" <ri****@rickou.net> wrote in message
news:3f**********************@news.free.fr...
hi all !!!
i need to call this API :
FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD
Flags)

i have a sample code in C++ that work fine...
FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD

Flags)

FT_STATUS ftStatus;
DWORD numDevs;

ftStatus = ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY);
char Buf[64];
ftStatus = ListDevices((PVOID)numDevs, buffer,

FT_LIST_BY_INDEX|FT_OPEN_BY_DESCRIPTION);

but i don't know how i can convert it on VB.NET

thank a lot !

Nov 20 '05 #2
hi rob,

thank for your answer.
i have try what you say but it don't work too..
for your info:
FT_STATUS is long

when i call :
ftStatus = ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY); the API should put in numDevs the number of devices it can access.

this call work fine...OK

but when i call the second : ftStatus = ListDevices((PVOID)numDevs, buffer,
FT_LIST_BY_INDEX|FT_OPEN_BY_DESCRIPTION);
the device should put in buffer (which is an array of 64 byte) the name of
the device (from index numDevs). numDevs is Long. but it don't work (the API
return in ftStatus that device doesn't exist)..

i have try the exemple in VC++ then it work fine (all two calls !!),

i have try to replace (PVOID)numDevs in second call by &numDevs and this
don't work..(the API return in ftStatus that device not exist, like with VB
!)

thank for your help...
FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD

Flags)
Nov 20 '05 #3
OK, sounds more and more like the kind of C programmer I want to hate.
They appear to have created the 1st parameter as both a number and a
pointer.
If you ever find the programmer of this API, shoot him.
Your safest bet is to create TWO api declare statements with different
Aliases.
One passes the 1st parameter ByValue and the other passes the 1st parameter
ByRef.

Also, Long in C = Integer in VB.NET and C#.

-Rob Teixeira [MVP]

"Eric BOUXIROT" <ri****@rickou.net> wrote in message
news:3f**********************@news.free.fr...
hi rob,

thank for your answer.
i have try what you say but it don't work too..
for your info:
FT_STATUS is long

when i call :
> ftStatus = ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY); the API should put in numDevs the number of devices it can access.

this call work fine...OK

but when i call the second : > ftStatus = ListDevices((PVOID)numDevs, buffer, FT_LIST_BY_INDEX|FT_OPEN_BY_DESCRIPTION);
the device should put in buffer (which is an array of 64 byte) the name of
the device (from index numDevs). numDevs is Long. but it don't work (the API return in ftStatus that device doesn't exist)..

i have try the exemple in VC++ then it work fine (all two calls !!),

i have try to replace (PVOID)numDevs in second call by &numDevs and this
don't work..(the API return in ftStatus that device not exist, like with VB !)

thank for your help...
FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID
pArg2,DWORD Flags)

Nov 20 '05 #4
Hello, Eric:

You will need (as Rob said) different declarations for the three different flags:
declare function FT_ListDevices1 lib "FTD2XX.DLL" alias "FT_ListDevices" (byref pArg1 as int32, byval pArg2 as int32, byval Flags as int32) as int32 'For FT_LIST_NUMBER_ONLY
declare ansi function FT_ListDevices2 lib "FTD2XX.DLL" alias "FT_ListDevices" (byval pArg1 as int32, byval pArg2 as string, byval Flags as int32) as int32 'For FT_LIST_BY_INDEX
declare ansi function FT_ListDevices3 lib "FTD2XX.DLL" alias "FT_ListDevices" (byval pArg1 as int32, byref pArg2 as string(), byval Flags as int32) as int32 'For FT_LIST_ALL (I don't know if it will work)

Remember that each string must be at least 64 characters long before calling the function.

Regards.
"Eric BOUXIROT" <ri****@rickou.net> escribió en el mensaje news:3f**********************@news.free.fr...
| hi all !!!
| i need to call this API :
| FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD
| Flags)
|
| i have a sample code in C++ that work fine...
|
| > FTD2XX_API FT_STATUS WINAPI FT_ListDevices(PVOID pArg1,PVOID pArg2,DWORD
| Flags)
| >
| > FT_STATUS ftStatus;
| > DWORD numDevs;
| >
| > ftStatus = ListDevices(&numDevs, NULL, FT_LIST_NUMBER_ONLY);
| > char Buf[64];
| > ftStatus = ListDevices((PVOID)numDevs, buffer,
| FT_LIST_BY_INDEX|FT_OPEN_BY_DESCRIPTION);
|
| but i don't know how i can convert it on VB.NET
|
| thank a lot !

Nov 20 '05 #5
Thank to you José and Rob !!!

after 1 day of hard search, this shit of API work....
Big Thank !!

i have one more question...
with this call
declare ansi function FT_ListDevices2 lib "FTD2XX.DLL" alias
"FT_ListDevices" (byval pArg1 as int32, byval pArg2 as string, byval Flags
as int32) as int32 'For FT_LIST_BY_INDEX
now i get a string ok but it seem to be incomplete..i explain..
when i break the program and in execution windows i type
? buffer (which is my string buffer with 65 Spaces)
i get
"123456
but there isn't the " at the end of string....

now i change the declare to use array of 64 bytes...
and add each byte to my string buffer with CHR instruction...
now when i ? buffer i get correct
"123456"
......
i don't know why...

thank a lot for your help !

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
45
by: Joh | last post by:
hello, i'm trying to understand how i could build following consecutive sets from a root one using generator : l = would like to produce : , , , ,
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
8
by: Sai Kit Tong | last post by:
In the article, the description for "Modiy DLL That Contains Consumers That Use Managed Code and DLL Exports or Managed Entry Points" suggests the creation of the class ManagedWrapper. If I...
9
by: Bill Borg | last post by:
Hello, I call a function recursively to find an item that exists *anywhere* down the chain. Let's say I find it five layers deep. Now I've got what I need and want to break out of that whole...
1
by: sommarlov | last post by:
Hi everyone >From one of our systems an xml file is produced. I need to validate this file before we send it to an external system for a very lenghty process. I cannot change the xml file layout....
18
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
4
by: sara | last post by:
i am studying a computer engineering and i started taking programming using C++ since month i have question i think it`s easy for you all *prof.programmer* but it`s bit diffecult for me plzz i...
5
by: bean330 | last post by:
Hey, I'm somewhat new to C# and I need a little help, please! I'm selecting a bunch of records, setting properties on a COM executable and then calling a method on that executable to run. I...
0
by: Siyodia | last post by:
This is a java program which i need to run facing compilation error Its consuming a third party web service method I have the supported files(folder) which contain necessary class files...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.