AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Records von Delphi in VB6 verwenden
Thema durchsuchen
Ansicht
Themen-Optionen

Records von Delphi in VB6 verwenden

Ein Thema von EWeiss · begonnen am 22. Feb 2015 · letzter Beitrag vom 23. Feb 2015
Antwort Antwort
Seite 1 von 3  1 23      
EWeiss
(Gast)

n/a Beiträge
 
#1

Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 17:34
Vorab es kann was länger werden.

Vergleich von Records und Types in VB
VB!
Alignment bedeutet dass die Variablen an einem Raster einer bestimmten Anzahl Bytes ausgerichtet werden.
Packed Record bedeutet dass ein Alignment von 1 verwendet wird, was soviel bedeutet wie dass kein Alignemnt verwendet werden soll.
z.B. bei einem Alignment von 4 (ist in VB üblich) werden die Variablen an einem Raster von 4 Bytes ausgerichtet.

zur Verdeutlichung ein kleines Beispiel:
Code:
Private Type TA1
    v1 As Integer ' 2 
    v2 As Integer ' 2
    v3 As Long    ' 4
End Type          

Private Type TA2
    v1 As Byte ' 1
    v2 As Long ' 4
End Type      

Private Sub Form_Load()
    Dim t1 As TA1
    MsgBox LenB(t1) '8 wie zu erwarten
   
    Dim t2 As TA1
    MsgBox LenB(t2) ' auch 8 !
   
End Sub
Habe dem Programmiere der DLL mitgeteilt das er die Records auf Packet umstellen soll.
Soweit so gut!
Nun mein Problem.
Trotz Packet kommen bei mir bei verschiedenen Records falsche werte an.

Die Functionen.
t_TagsLibrary_GetAudioAttributes = function (Tags: HTags; AudioType: TAudioType; Attributes: Pointer): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
Code:
Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByRef Attributes As Any) As Long
Die erste Type/Record.
Delphi-Quellcode:
type
    PAudioAttributes = ^TAudioAttributes;
    TAudioAttributes = packed record
        Channels: DWord; // number of channels (i.e. mono, stereo, etc.)
        SamplesPerSec: DWord; //sample rate
        BitsPerSample: DWord; //number of bits per sample of mono data
        PlayTime: Double;
        SampleCount: UInt64;
        BitRate: Integer;
    end;
Code:
Public Type TAudioAttributes
    Channels     As Long     ' number of channels (i.e. mono, stereo, etc.)
    SamplesPerSec As Long     ' sample rate
    BitsPerSample As Long     ' number of bits per sample of mono data
    PlayTime     As Double   ' duration in seconds
    SampleCount  As Currency ' number of total samples
    Bitrate      As Long
End Type
Die abfrage function
Code:
Public Sub GetAudioAttributes(ByVal AudioType As TAudioType)

Dim AudioAttributes As TAudioAttributes

    If AudioType = atAutomatic Then
        TagsLibrary_GetAudioAttributes LngTags, AudioType, AudioAttributes

        AttributesChannels = AudioAttributes.Channels
        AttributesSamplesPerSec = AudioAttributes.SamplesPerSec
        AttributesBitsPerSample = AudioAttributes.BitsPerSample
        AttributesPlayTime = AudioAttributes.PlayTime
        AttributesSampleCount = AudioAttributes.SampleCount
        AttributesBitrate = AudioAttributes.Bitrate
    End If

End Sub
Werte werden richtig zurückgegeben.

zweite Record
Delphi-Quellcode:
type
    PMPEGAudioAttributes = ^TMPEGAudioAttributes;
    TMPEGAudioAttributes = packed record
        Position: Int64; //* Position of header in bytes
        Header: DWord; //* The Headers bytes
        FrameSize: Integer; //* Frame's length
        Version: TMPEGVersion; //* MPEG Version
        Layer: TMPEGLayer; //* MPEG Layer
        CRC: LongBool; //* Frame has CRC
        BitRate: DWord; //* Frame's bitrate
        SampleRate: DWord; //* Frame's sample rate
        Padding: LongBool; //* Frame is padded
        _Private: LongBool; //* Frame's private bit is set
        ChannelMode: TMPEGChannelMode; //* Frame's channel mode
        ModeExtension: TMPEGModeExtension; //* Joint stereo only
        Copyrighted: LongBool; //* Frame's Copyright bit is set
        Original: LongBool; //* Frame's Original bit is set
        Emphasis: TMPEGEmphasis; //* Frame's emphasis mode
        VBR: LongBool; //* Stream is probably VBR
        FrameCount: Int64; //* Total number of MPEG frames (by header)
        Quality: Integer; //* MPEG quality
        Bytes: Int64; //* Total bytes
    end;
Code:
Public Type TMPEGAudioAttributes
    Position     As Currency              '* Position of header in bytes
    Header       As Long                  '* The Headers bytes
    FrameSize    As Long                  '* Frame's length
    Version      As TMPEGVersion          '* MPEG Version
    Layer        As TMPEGLayer            '* MPEG Layer
    CRC          As Long                  '* Frame has CRC
    Bitrate      As Long                  '* Frame's bitrate
    SampleRate   As Long                  '* Frame's sample rate
    Padding      As Long                  '* Frame is padded
    Private_      As Long                  '* Frame's private bit is set
    ChannelMode  As TMPEGChannelMode      '* Frame's channel mode
    ModeExtension As TMPEGModeExtension    '* Joint stereo only
    Copyrighted  As Long                  '* Frame's Copyright bit is set
    Original     As Long                  '* Frame's Original bit is set
    Emphasis     As TMPEGEmphasis         '* Frame's emphasis mode
    VBR          As Long                  '* Stream is probably VBR
    FrameCount   As Currency              '* Total number of MPEG frames (by header)
    Quality      As Long                  '* MPEG quality
    Bytes        As Currency              '* Total bytes
End Type
Die abfrage function
Code:
Public Sub GetMPEGAudioAttributes(ByVal AudioType As TAudioType)

Dim MPGAudioAttributes As TMPEGAudioAttributes

    If AudioType = atMPEG Then
        TagsLibrary_GetAudioAttributes LngTags, AudioType, MPGAudioAttributes

        MPGAttributesPosition = MPGAudioAttributes.Position
        MPGAttributesHeader = MPGAudioAttributes.Header
        MPGAttributesFrameSize = MPGAudioAttributes.FrameSize
        MPGAttributesVersion = MPGAudioAttributes.Version
        MPGAttributesLayer = MPGAudioAttributes.Layer
        MPGAttributesCRC = MPGAudioAttributes.CRC
        MPGAttributesBitrate = MPGAudioAttributes.Bitrate
        MPGAttributesSampleRate = MPGAudioAttributes.SampleRate
        MPGAttributesPadding = MPGAudioAttributes.Padding
        MPGAttributesPrivate_ = MPGAudioAttributes.Private_
        MPGAttributesChannelMode = MPGAudioAttributes.ChannelMode
        MPGAttributesModeExtension = MPGAudioAttributes.ModeExtension
        MPGAttributesCopyrighted = MPGAudioAttributes.Copyrighted
        MPGAttributesOriginal = MPGAudioAttributes.Original
        MPGAttributesEmphasis = MPGAudioAttributes.Emphasis
        MPGAttributesVBR = MPGAudioAttributes.VBR
        MPGAttributesFrameCount = MPGAudioAttributes.FrameCount
        MPGAttributesQuality = MPGAudioAttributes.Quality
        MPGAttributesBytes = MPGAudioAttributes.Bytes
    End If

End Sub
Wie man sehen kann sind beide abfragen (GetMPEGAudioAttributes\GetAudioAttributes) vom Aufbau gleich.
Trotzdem sind die Rückgabewerte von GetMPEGAudioAttributes falsch.

Kann mir nun jemand sagen woran das liegen könnte..
Warum sind die Abfragen beim ersten Record richtig und beim zweiten wiederum nicht!
Meine Vermutung ist das die Typen Int64 mit VB6 nicht kompatibel sind obwohl Currency und Int64 jeweils 8 Byte groß sind.

Hoffe das sich jemand die mühe macht das durchzulesen.

gruss

Geändert von EWeiss (22. Feb 2015 um 18:09 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#2

AW: Records von Delphi in VB verwenden

  Alt 22. Feb 2015, 17:40
Kleiner Tippfehler im Beitrag: Es sind 8 Byte und nicht 8 Bit

Gibt es einen Grund, warum dort mal UInt64 und mal Int64 zu Currency gemappt wird?

Gibt es unter VB keinen Int64 -Typen?
Doch, gibt es: https://msdn.microsoft.com/en-us/library/47zceaw7.aspx

EDIT Ok, VB6 kennt es nicht https://msdn.microsoft.com/en-us/lib...=vs.60%29.aspx

Hier mal im Vergleich die Delphi-Typen
http://docwiki.embarcadero.com/RADSt...e_Datenformate
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)

Geändert von Sir Rufo (22. Feb 2015 um 18:28 Uhr)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#3

AW: Records von Delphi in VB verwenden

  Alt 22. Feb 2015, 18:02
Zitat:
Kleiner Tippfehler im Beitrag: Es sind 8 Byte und nicht 8 Bit
Danke werde es berichtigen

Zitat:
Gibt es einen Grund, warum dort mal UInt64 und mal Int64 zu Currency gemappt wird?
Ja weil VB6 nur Currency als alternative kennt also 8 Byte
Zudem muss ich die gleiche Anzahl an Bytes verwenden damit der Recordsize gleich bleibt.
Mein Unverständnis. Frage mich warum überhaupt bei 32 Bit Anwendungen UInt64/Int64 verwendet werden.
Macht das sinn?
Warum UInt64 und mal Int64 entzieht sich meiner Kenntnis müsste ich den Developer der DLL mal fragen.

Zitat:
Gibt es unter VB keinen Int64 -Typen?
Doch, gibt es: https://msdn.microsoft.com/en-us/library/47zceaw7.aspx
Leider nein.
Nicht verwechseln VB6 nicht VB.NET
Hab den Thread Titel geändert

Zitat:
Hier mal im Vergleich die Delphi-Typen
http://docwiki.embarcadero.com/RADSt...e_Datenformate
Danke!
Interessant und immer gut wenn man so eine Tabelle hat.

Geändert von EWeiss (22. Feb 2015 um 18:17 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von ConnorMcLeod
ConnorMcLeod

Registriert seit: 13. Okt 2010
Ort: Bayern
490 Beiträge
 
Delphi 10.4 Sydney
 
#4

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 18:38
Quatsch, nicht alles gelesen gehabt ...
Nr.1 Delphi-Tool: [F7]

Geändert von ConnorMcLeod (22. Feb 2015 um 18:45 Uhr)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#5

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 18:44
Das erste Mal mappste Currency auf UInt64 und das zweite Mal auf Int64. Vllt isses das?
Wo?
Es sind doch unterschiedliche Records.
Und komplett von einander getrennt.

Und werden separat aufgerufen
Code:
TagsLibrary_GetAudioAttributes LngTags, AudioType, AudioAttributes
TagsLibrary_GetAudioAttributes LngTags, AudioType, MPGAudioAttributes
gruss

Geändert von EWeiss (22. Feb 2015 um 18:47 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von ConnorMcLeod
ConnorMcLeod

Registriert seit: 13. Okt 2010
Ort: Bayern
490 Beiträge
 
Delphi 10.4 Sydney
 
#6

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 18:51
Da: (aber ich glaube, das hattet Ihr schon besprochen, oder?)

Die erste Type/Record.
Delphi-Quellcode:
type
    TAudioAttributes = packed record
        SampleCount: UInt64;
    end;
Code:
Public Type TAudioAttributes
    SampleCount  As Currency ' number of total samples
End Type
zweite Record
Delphi-Quellcode:
type
    TMPEGAudioAttributes = packed record
        Position: Int64; //* Position of header in bytes
        FrameCount: Int64; //* Total number of MPEG frames (by header)
        Bytes: Int64; //* Total bytes
    end;
Code:
Public Type TMPEGAudioAttributes
    Position     As Currency              '* Position of header in bytes
    FrameCount   As Currency              '* Total number of MPEG frames (by header)
    Bytes        As Currency              '* Total bytes
End Type
Nr.1 Delphi-Tool: [F7]
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#7

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 19:03
Wenn ich mir Int64 und UInt64 ansehe, hätte ich schon fast gedacht, da müsste Int64 besser passen (Vorzeichen-Bit, aber ...

... Currency wird als Container für 8 Bytes ge(miss)braucht, von daher würde ich da auf jeden Fall mal Int64 gegen UInt64 bzw. Cardinal (das Gleiche in grün) tauschen.

Delphi-Quellcode:
type
    PMPEGAudioAttributes = ^TMPEGAudioAttributes;
    TMPEGAudioAttributes = packed record
        Position: UInt64; //* Position of header in bytes
        Header: DWord; //* The Headers bytes
        FrameSize: Integer; //* Frame's length
        Version: TMPEGVersion; //* MPEG Version
        Layer: TMPEGLayer; //* MPEG Layer
        CRC: LongBool; //* Frame has CRC
        BitRate: DWord; //* Frame's bitrate
        SampleRate: DWord; //* Frame's sample rate
        Padding: LongBool; //* Frame is padded
        _Private: LongBool; //* Frame's private bit is set
        ChannelMode: TMPEGChannelMode; //* Frame's channel mode
        ModeExtension: TMPEGModeExtension; //* Joint stereo only
        Copyrighted: LongBool; //* Frame's Copyright bit is set
        Original: LongBool; //* Frame's Original bit is set
        Emphasis: TMPEGEmphasis; //* Frame's emphasis mode
        VBR: LongBool; //* Stream is probably VBR
        FrameCount: UInt64; //* Total number of MPEG frames (by header)
        Quality: Integer; //* MPEG quality
        Bytes: UInt64; //* Total bytes
    end;
Edit

Ok, hört sich auch irgendwie nach Voodoo an (wenn ich so länger drüber sinniere).

Wie sind denn diese TMPEG... Typen definiert? Enums, Records, ...?
Bei Enums muss man aufpassen, denn die können unterschiedliche Byte-Längen haben (wenn man da nicht einwirkt).
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)

Geändert von Sir Rufo (22. Feb 2015 um 19:14 Uhr)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#8

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 19:07
Zitat:
Da: (aber ich glaube, das hattet Ihr schon besprochen, oder?)
Ja
Aber wie gesagt Currency ist ja nur der vergleich Daten Type für UInt64 und Int64
Um den Record in der Größe gleichzuhalten muss ich einen Daten Type von 8 Bytes verwenden.

Auch wenn er signiert bzw. unsigniert nicht gleich ist mit den in Delphi deklarierten Typ
Currency = 6,312
Int64 = 63120

Das sind dann halt die Unterschiede.

Wie schon gesagt die Records sind voneinander getrennt warum er jetzt einmal UInt64 und Int64 verwendet?
Kein Ahnung..

gruss
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#9

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 19:10
Zitat:
von daher würde ich da auf jeden Fall mal Int64 gegen UInt64 bzw. Cardinal (das Gleiche in grün) tauschen.
Danke werde ihm das mal vorschlagen da ich keinen zugriff auf dem Quelltext habe.

gruss

Geändert von EWeiss (22. Feb 2015 um 19:15 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von Sir Rufo
Sir Rufo

Registriert seit: 5. Jan 2005
Ort: Stadthagen
9.454 Beiträge
 
Delphi 10 Seattle Enterprise
 
#10

AW: Records von Delphi in VB6 verwenden

  Alt 22. Feb 2015, 19:17
Zitat:
von daher würde ich da auf jeden Fall mal Int64 gegen UInt64 bzw. Cardinal (das Gleiche in grün) tauschen.
Danke werde ihm das mal vorschlagen da ich keinen zugriff auf dem Quelltext habe.

gruss
Nee, das wird es wohl nicht sein, ich tippe eher mal auf die TMPEG... Typen. Was ist das, bzw. wie sind die deklariert? (s. Edit meiner Antwort)
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ‎ea 0a 4c 14 0d b6 3a a4 c1 c5 b9 dc 90 9d f0 e9 de 13 da 60)
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 3  1 23      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:21 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz