Einzelnen Beitrag anzeigen

Daniel G
(Gast)

n/a Beiträge
 
#7

Re: Warum verursacht diese Zeile eine AV?

  Alt 15. Aug 2005, 22:22
Hmm... Ok, die AV ist weg. Mal sehen, wie das jetzt weiter geht....

Ich hatte mich an dem orig. Microsoft - Code orientiert:

Code:
DoPrintData(((PSENDCMDOUTPARAMS)AttrOutCmd)->bBuffer,
      ((PSENDCMDOUTPARAMS)ThreshOutCmd)->bBuffer,
                     i);
"DoPrintData" ist dabei wie folgt deklariert:

Code:
VOID DoPrintData(PCHAR pAttrBuffer, PCHAR pThrsBuffer, BYTE bDriveNum)
int   i;
PDRIVEATTRIBUTE   pDA;
PATTRTHRESHOLD   pAT;
BYTE Attr;

   //
   // Print the drive number
   //
   printf("\nData for Drive Number %d\n", bDriveNum);
   //
   // Print the revisions of the data structures
   //
   printf("Attribute Structure Revision         Threshold Structure Revision\n");
   printf("            %d                                     %d\n\n",
            (WORD)pAttrBuffer[0],
            (WORD)pThrsBuffer[0]);

   //
   // Print the header and loop through the structures, printing
   // the structures when the attribute ID is known.
   //
   printf("  -Attribute Name-      -Attribute Value-     -Threshold Value-\n");

   pDA = (PDRIVEATTRIBUTE)&pAttrBuffer[2];
   pAT = (PATTRTHRESHOLD)&pThrsBuffer[2];

   for (i = 0; i < NUM_ATTRIBUTE_STRUCTS; i++)
   {
      Attr = pDA->bAttrID;
      if (Attr)
      {
         if (Attr > MAX_KNOWN_ATTRIBUTES)
            Attr = MAX_KNOWN_ATTRIBUTES+1;
         printf("%2X %-29s%d%20c%d\n",
               pDA->bAttrID,
               pAttrNames[Attr],
               pDA->bAttrValue,
               ' ',
               pAT->bWarrantyThreshold );
      }
      pDA++;
      pAT++;
   }

}
Zum Testen habe ich mir die erste Variable geschnappt:

pAttrBuffer: PChar Und dann dachte ich halt, das obige würde in Delphi so aussehen:
PChar(PSENDCMDOUTPARAMS(AttrOutCmd).bBuffer[0]) Oder hab' ich das damit völlig verhauen? Ich mochte "C" noch nie....
  Mit Zitat antworten Zitat