![]() |
record? von C nach Delphi
Hallo,
ich habe in C diesen Code:
Code:
LIST_ENTRY ist in der winnt.h so definiert:
LIST_ENTRY EnumeratedHCListHead =
{ &EnumeratedHCListHead, &EnumeratedHCListHead };
Code:
Das an sich stellt nicht das Problem da, da in der Windows.pas (Delphi) eine entsprchende Definition vorhanden ist:
typedef struct _LIST_ENTRY {
struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
Delphi-Quellcode:
Doch wie stelle ich EnumeratedHCListHead da?
PListEntry = ^TListEntry;
_LIST_ENTRY = record Flink: PListEntry; Blink: PListEntry; end; {$EXTERNALSYM _LIST_ENTRY} TListEntry = _LIST_ENTRY; LIST_ENTRY = _LIST_ENTRY; {$EXTERNALSYM LIST_ENTRY} |
AW: record? von C nach Delphi
Wo genau ist denn jetzt das Problem bzw. die Frage?
Die Eigenschaften Flink und Blink zeigen beim Kopf halt ganz einfach auf den Kopf selbst... Also EnumeratedHCListHead vom Typ TListEntry erzeugen und die beiden Zeiger darauf zeigen lassen. |
AW: record? von C nach Delphi
Ich glaube ich komme darauf noch einmal zurück.
Behelfe mich jetzt erst einmal so:
Delphi-Quellcode:
Mal sehen wie weit ich damit komme.
listEntry := new(PListEntry);
Bis hier her. Es scheint etwas komplizierter zu sein. Zum besseren Verständnis mal die ganze Routine:
Code:
Hängen bleibe ich nun hier:
VOID
EnumerateHostController ( HTREEITEM hTreeParent, HANDLE hHCDev, __in PTSTR leafName ) { PTSTR driverKeyName; PTSTR deviceDesc; PTSTR deviceId; HTREEITEM hHCItem; PTSTR rootHubName; PLIST_ENTRY listEntry; PUSBHOSTCONTROLLERINFO hcInfo; PUSBHOSTCONTROLLERINFO hcInfoInList; // Allocate a structure to hold information about this host controller. // hcInfo = (PUSBHOSTCONTROLLERINFO)ALLOC(sizeof(USBHOSTCONTROLLERINFO)); if (hcInfo != NULL) { hcInfo->DeviceInfoType = HostControllerInfo; // Obtain the driver key name for this host controller. // driverKeyName = GetHCDDriverKeyName(hHCDev); if (driverKeyName) { // Don't enumerate this host controller again if it already // on the list of enumerated host controllers. // listEntry = EnumeratedHCListHead.Flink; while (listEntry != &EnumeratedHCListHead) { hcInfoInList = CONTAINING_RECORD(listEntry, USBHOSTCONTROLLERINFO, ListEntry); if (_tcscmp(driverKeyName, hcInfoInList->DriverKey) == 0) { // Already on the list, exit // FREE(driverKeyName); FREE(hcInfo); return; } listEntry = listEntry->Flink; } // Obtain the device id string for this host controller. // (Note: this a tmp global string buffer, make a copy of // this string if it will used later.) // deviceId = DriverNameToDeviceDesc(driverKeyName, TRUE); if (deviceId) { ULONG ven, dev, subsys, rev; if (_stscanf_s(deviceId, _T("PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x"), &ven, &dev, &subsys, &rev) != 4) { OOPS(); } hcInfo->DriverKey = driverKeyName; hcInfo->VendorID = ven; hcInfo->DeviceID = dev; hcInfo->SubSysID = subsys; hcInfo->Revision = rev; } else { OOPS(); } // Obtain the device description string for this host controller. // (Note, this a tmp global string buffer, make a copy of // this string if it will be used later.) // deviceDesc = DriverNameToDeviceDesc(driverKeyName, FALSE); if (deviceDesc) { leafName = deviceDesc; } else { OOPS(); } // Add this host controller to the USB device tree view. // hHCItem = AddLeaf(hTreeParent, (LPARAM)hcInfo, leafName, GoodDeviceIcon); if (hHCItem) { // Add this host controller to the list of enumerated // host controllers. // InsertTailList(&EnumeratedHCListHead, &hcInfo->ListEntry); // Get the name of the root hub for this host // controller and then enumerate the root hub. // rootHubName = GetRootHubName(hHCDev); if (rootHubName != NULL) { if (EnumerateHub(hHCItem, rootHubName, NULL, // ConnectionInfo NULL, // ConfigDesc NULL, // StringDescs _T("RootHub") // DeviceDesc ) == FALSE) { FREE(rootHubName); } } else { // Failure obtaining root hub name. OOPS(); } } else { // Failure adding host controller to USB device tree // view. OOPS(); FREE(driverKeyName); FREE(hcInfo); } } else { // Failure obtaining driver key name. OOPS(); FREE(hcInfo); } } }
Code:
Wie müsste ich das angehen?
...
listEntry = EnumeratedHCListHead.Flink; while (listEntry != &EnumeratedHCListHead) ... Danke. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:43 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz