Help: Delphi Code To VB6 Code
How does Delphi master convert the following code to VB6 code
Code:
function TAPETag.RemoveTagFromFile(sFile: WideString): Boolean;
var
SourceFile: TTntFileStream;
Footer: RTagHeader;
ID3: pointer;
begin
Result := ReadFooter(sFile, Footer);
{ Process data if loaded and footer valid }
if (Result) and (Footer.ID = APE_ID) then
begin
SourceFile := TTntFileStream.Create(sFile, fmOpenReadWrite or fmShareDenyWrite);
{ If there is an ID3v1 tag roaming around behind the APE tag, we have to buffer it }
if Footer.DataShift = ID3V1_TAG_SIZE then
begin
GetMem(ID3,ID3V1_TAG_SIZE);
SourceFile.Seek(footer.FileSize - footer.DataShift, soFromBeginning);
SourceFile.Read(ID3^, ID3V1_TAG_SIZE);
end;
{ If this is an APEv2, header size must be added }
if (Footer.Flags shr 31) > 0 then
Inc(Footer.Size, APE_TAG_HEADER_SIZE);
SourceFile.Seek(Footer.FileSize - footer.Size-Footer.DataShift, soFromBeginning);
{ If there is an ID3v1 tag roaming around, we copy it }
if Footer.DataShift = ID3V1_TAG_SIZE then
begin
SourceFile.Write(ID3^, ID3V1_TAG_SIZE);
FreeMem(ID3,128);
end;
SourceFile.Seek(Footer.FileSize-Footer.Size, soFromBeginning);
//truncate
SourceFile.Size := SourceFile.Position;
SourceFile.Free;
end;
end;
Re: Help: Delphi Code To VB6 Code
Quote:
Originally Posted by
Polosa
How does Delphi master convert the following code to VB6 code
Code:
function TAPETag.RemoveTagFromFile(sFile: WideString): Boolean;
var
SourceFile: TTntFileStream;
Footer: RTagHeader;
ID3: pointer;
begin
Result := ReadFooter(sFile, Footer);
{ Process data if loaded and footer valid }
if (Result) and (Footer.ID = APE_ID) then
begin
SourceFile := TTntFileStream.Create(sFile, fmOpenReadWrite or fmShareDenyWrite);
{ If there is an ID3v1 tag roaming around behind the APE tag, we have to buffer it }
if Footer.DataShift = ID3V1_TAG_SIZE then
begin
GetMem(ID3,ID3V1_TAG_SIZE);
SourceFile.Seek(footer.FileSize - footer.DataShift, soFromBeginning);
SourceFile.Read(ID3^, ID3V1_TAG_SIZE);
end;
{ If this is an APEv2, header size must be added }
if (Footer.Flags shr 31) > 0 then
Inc(Footer.Size, APE_TAG_HEADER_SIZE);
SourceFile.Seek(Footer.FileSize - footer.Size-Footer.DataShift, soFromBeginning);
{ If there is an ID3v1 tag roaming around, we copy it }
if Footer.DataShift = ID3V1_TAG_SIZE then
begin
SourceFile.Write(ID3^, ID3V1_TAG_SIZE);
FreeMem(ID3,128);
end;
SourceFile.Seek(Footer.FileSize-Footer.Size, soFromBeginning);
//truncate
SourceFile.Size := SourceFile.Position;
SourceFile.Free;
end;
end;
:confused: What does that mean...???
Re: Help: Delphi Code To VB6 Code
It means exactly what it says: convert Delphi to VB6.
@Polosa:
it won't be possible to convert due to number of "missing" functionalities in VB6 mplus some recursice calls to other functions (ReadFooter, GetMem, Inc, etc)...
Implementing similar logic won't be difficult as long as you know file structure.
All that piece of code does is
- opens file
- validates footer (define footer)
- checks for some "tags" (ID3v1 and APE) and if found it does something
Again, depending on the file structure ,you can use Open For Input/Binary/Random tecniques to read and parse (perhaps using InStr, Left, etc functions).
If you can post sample file and describe what you need out of it I'm sure you will get decent replies.
Re: Help: Delphi Code To VB6 Code
Quote:
Originally Posted by
RhinoBull
It means exactly what it says: convert Delphi to VB6.
Oh.. sorry... I thought it in different way... :o
Re: Help: Delphi Code To VB6 Code
You might want to keep searching. Maybe this forum, psc, and google for vb6 examples. Parsing ID3 tags using VB has been around for quite awhile.
Re: Help: Delphi Code To VB6 Code
Today, try to write code to delete ID3 tags, OK
But remove the APE tags I still do not understand, his header and footer are "APETAGEX" length is 32
Item length, but not the same, so I have been unable to complete its written judgments.
Sorry my English is bad, we do not know can understand my problem?
Attached test music and Delphi Code.
test music :Http://FileDeck.net/files/1MTDV5V7/43 - Fanfare.ape
Delphi Code:Http://FileDeck.net/files/PKJAQDHM/APE Tag.zip
Delete ID3 V1
Code:
Private Sub DeleteTag(ByVal nFileNew As String, ByVal nFileOld As String)
Dim fileNumNew As Long
Dim fileNumOld As Long
Dim audioEndPos As Long
Dim tag As String
tag = String(3, " ")
fileNumOld = FreeFile
Open nFileOld For Binary As #fileNumOld
audioEndPos = LOF(fileNumOld)
' ID3v1
If audioEndPos > 128 Then
Get #fileNumOld, audioEndPos - 127, tag
If tag = "TAG" Then audioEndPos = audioEndPos - 128
End If
fileNumNew = FreeFile
Open nFileNew For Binary As #fileNumNew
Dim endPos As Long
Dim copyData() As Byte
If audioEndPos > 1 Then
ReDim Preserve copyData(audioEndPos - 1)
Get #fileNumOld, 1, copyData
endPos = LOF(fileNumNew)
Put #fileNumNew, endPos + 1, copyData
End If
Close #fileNumNew
Close #fileNumOld
End Sub
Re: Help: Delphi Code To VB6 Code
Best suggestion in this case is look for a solution in either VB6 or VB.NET, that is if you have a copy of Visual Studio as you are more likely to find something there or for that matter match .NET to Delphi as Delphi is the mother of .NET.
It's fairly simply to use the free interop library to marry .NET to VB6.
In regards to the Delphi code, I notice some missing parts that are not exposed and also the coder is making use of pointers which means you need to work around that.