Results 1 to 7 of 7

Thread: Help: Delphi Code To VB6 Code

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    6

    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;

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Help: Delphi Code To VB6 Code

    Quote Originally Posted by Polosa View Post
    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;
    What does that mean...???

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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.

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Help: Delphi Code To VB6 Code

    Quote Originally Posted by RhinoBull View Post
    It means exactly what it says: convert Delphi to VB6.
    Oh.. sorry... I thought it in different way...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    6

    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
    Last edited by Polosa; Feb 17th, 2010 at 10:45 PM.

  7. #7
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width