![]() |
Records von Delphi in VB6 verwenden
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:
Habe dem Programmiere der DLL mitgeteilt das er die Records auf Packet umstellen soll.
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 Soweit so gut! Nun mein Problem. Trotz Packet kommen bei mir bei verschiedenen Records falsche werte an. Die Functionen.
Delphi-Quellcode:
t_TagsLibrary_GetAudioAttributes = function (Tags: HTags; AudioType: TAudioType; Attributes: Pointer): LongBool; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
Code:
Die erste Type/Record.
Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByRef Attributes As Any) As Long
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:
Die abfrage function
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
Code:
Werte werden richtig zurückgegeben.
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 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:
Die abfrage function
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
Code:
Wie man sehen kann sind beide abfragen (GetMPEGAudioAttributes\GetAudioAttributes) vom Aufbau gleich.
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 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 |
AW: Records von Delphi in VB verwenden
Kleiner Tippfehler im Beitrag: Es sind 8 Byte und nicht 8 Bit
Gibt es einen Grund, warum dort mal
Delphi-Quellcode:
und mal
UInt64
Delphi-Quellcode:
zu
Int64
Delphi-Quellcode:
gemappt wird?
Currency
Gibt es unter VB keinen
Delphi-Quellcode:
-Typen?
Int64
Doch, gibt es: ![]() EDIT Ok, VB6 kennt es nicht ![]() Hier mal im Vergleich die Delphi-Typen ![]() |
AW: Records von Delphi in VB verwenden
Zitat:
Zitat:
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:
Nicht verwechseln VB6 nicht VB.NET Hab den Thread Titel geändert ;) Zitat:
Interessant und immer gut wenn man so eine Tabelle hat. |
AW: Records von Delphi in VB6 verwenden
Quatsch, nicht alles gelesen gehabt ...
|
AW: Records von Delphi in VB6 verwenden
Zitat:
Es sind doch unterschiedliche Records. Und komplett von einander getrennt. Und werden separat aufgerufen
Code:
gruss
TagsLibrary_GetAudioAttributes LngTags, AudioType, AudioAttributes
TagsLibrary_GetAudioAttributes LngTags, AudioType, MPGAudioAttributes |
AW: Records von Delphi in VB6 verwenden
Da: (aber ich glaube, das hattet Ihr schon besprochen, oder?)
Zitat:
|
AW: Records von Delphi in VB6 verwenden
Wenn ich mir
Delphi-Quellcode:
und
Int64
Delphi-Quellcode:
ansehe, hätte ich schon fast gedacht, da müsste
UInt64
Delphi-Quellcode:
besser passen (Vorzeichen-Bit, aber ...
Int64
...
Delphi-Quellcode:
wird als Container für 8 Bytes ge(miss)braucht, von daher würde ich da auf jeden Fall mal
Currency
Delphi-Quellcode:
gegen
Int64
Delphi-Quellcode:
bzw.
UInt64
Delphi-Quellcode:
(das Gleiche in grün) tauschen.
Cardinal
Delphi-Quellcode:
Edit
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; Ok, hört sich auch irgendwie nach Voodoo an (wenn ich so länger drüber sinniere). Wie sind denn diese
Delphi-Quellcode:
Typen definiert? Enums, Records, ...?
TMPEG...
Bei Enums muss man aufpassen, denn die können unterschiedliche Byte-Längen haben (wenn man da nicht einwirkt). |
AW: Records von Delphi in VB6 verwenden
Zitat:
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 |
AW: Records von Delphi in VB6 verwenden
Zitat:
gruss |
AW: Records von Delphi in VB6 verwenden
Zitat:
Delphi-Quellcode:
Typen. Was ist das, bzw. wie sind die deklariert? (s. Edit meiner Antwort)
TMPEG...
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:17 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