title image


Smiley Problem eine DLL einzubinden
Hallo, ich muss einen USB Device einbinden, und habe dazu eine DLL:

DLL: http://www.ftdichip.com/Drivers/D2XX/Win2000/D30104.zip

User Guide: http://www.ftdichip.com/Documents/ProgramGuides/D2XXPG31.pdf

Anbieter der DLL: http://www.ftdichip.com/



Jetzt habe ich den Treiber auf meinem System installiert -> Hat alles geklappt -> Der USB Device wurde von XP erkannt!



jetzte habe ich die User Guide aufgemacht! -> leider ist der code darin in C++(glaube ich)



Beim Übersetzen nach pascal hatte ich so meine Probleme:



#Orginal code:



Get information concerning the devices currently connected. This function can return information such as the number of devices connected, the device serial number and device description strings, and the location IDs of connected devices.



FT_STATUS FT_ListDevices (PVOID pvArg1, PVOID pvArg2, DWORD dwFlags)



Parameters:



pvArg1 Meaning depends on dwFlags.

pvArg2 Meaning depends on dwFlags.

dwFlags Determines format of returned information.



Return Value:



FT_OK if successful, otherwise the return value is an FT error code.



Remarks:

This function can be used in a number of ways to return different types of information. ...



In its simplest form, it can be used to return the number of devices currently connected. If FT_LIST_NUMBER_ONLY bit is set in dwFlags, the parameter pvArg1 is interpreted as a pointer to a DWORD location to store the number of devices currently connected.



Examples:



The examples that follow use these variables:



FT_STATUS ftStatus;

-> Aus dem Anhang:

FT_STATUS (DWORD)

FT_OK = 0

FT_INVALID_HANDLE = 1

FT_DEVICE_NOT_FOUND = 2

FT_DEVICE_NOT_OPENED = 3

FT_IO_ERROR = 4

FT_INSUFFICIENT_RESOURCES = 5

FT_INVALID_PARAMETER = 6

FT_INVALID_BAUD_RATE = 7

FT_DEVICE_NOT_OPENED_FOR_ERASE = 8

FT_DEVICE_NOT_OPENED_FOR_WRITE = 9

FT_FAILED_TO_WRITE_DEVICE = 10

FT_EEPROM_READ_FAILED = 11

FT_EEPROM_WRITE_FAILED = 12

FT_EEPROM_ERASE_FAILED = 13

FT_EEPROM_NOT_PRESENT = 14

FT_EEPROM_NOT_PROGRAMMED = 15

FT_INVALID_ARGS = 16

FT_NOT_SUPPORTED = 17

FT_OTHER_ERROR = 18

->Ende Anhang

DWORD numDevs;



Get the number of devices currently connected:



ftStatus = FT_ListDevices(&numDevs,NULL,FT_LIST_NUMBER_ONLY);

if (ftStatus == FT_OK) {

// FT_ListDevices OK, number of devices connected is in numDevs

}

else {

// FT_ListDevices failed

}



# Mein Code:



...



const

FT_LIST_NUMBER_ONLY = 0x80000000;

FT_LIST_BY_INDEX = 0x40000000;

FT_LIST_ALL = 0x20000000;



FT_OK = 0;

FT_INVALID_HANDLE = 1;

FT_DEVICE_NOT_FOUND = 2;

FT_DEVICE_NOT_OPENED = 3;

FT_IO_ERROR = 4;

FT_INSUFFICIENT_RESOURCES = 5;

FT_INVALID_PARAMETER = 6;

FT_INVALID_BAUD_RATE = 7;

FT_DEVICE_NOT_OPENED_FOR_ERASE = 8;

FT_DEVICE_NOT_OPENED_FOR_WRITE = 9;

FT_FAILED_TO_WRITE_DEVICE = 10;

FT_EEPROM_READ_FAILED = 11;

FT_EEPROM_WRITE_FAILED = 12;

FT_EEPROM_ERASE_FAILED = 13;

FT_EEPROM_NOT_PRESENT = 14;

FT_EEPROM_NOT_PROGRAMMED = 15;

FT_INVALID_ARGS = 16;

FT_NOT_SUPPORTED = 17;

FT_OTHER_ERROR = 18;



implementation



{$R *.dfm}



function FT_ListDevices (a,b:pointer;c:DWord) :DWord;external 'FTD2XX.dll'; //Function aus DLL



procedure TForm1.Button1Click(Sender: TObject);

var a,b:dword;

begin



showmessage(inttostr(ft_ListDevices(@a,@b,FT_LIST_NUMBER_ONLY)));



{ Leider bekomme ich immer als result 6 zurück (FT_INVALID_PARAMETER = 6;)

wie im example gehts nicht:

showmessage(inttostr(ft_ListDevices(@a,nil,FT_LIST_NUMBER_ONLY)));}



end;



# Ende Code:



Ich brauche hierzu Hilfe... -> ich weiß nicht was ich falsch mache! -> wäre nett, wenn ihr euch die Zeit nehmen würdet!



Danke



Rylon t.H.D.
Rylon t. H. D.

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: