Results 1 to 23 of 23

Thread: [RESOLVED] Need help getting a pointer to UDT

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Resolved [RESOLVED] Need help getting a pointer to UDT

    I have been trying to work with a Tagging Library that was originally written in delphi and the author created a win32 dll.

    With the Help of Bonnie West the VB6 wrapper he supplied now works except for the following.

    In the bas wrapper he has;

    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
    
    Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByRef Attributes As Long) As Long
    And my simple test code looks like this;

    Code:
    Dim Tags As Long, TagAtts As TAudioAttributes
        Tags = TagsLibrary_Create
        TagsLibrary_Load Tags, StrPtr("C:\CD1Track01.wv"), ttAutomatic, True
        MsgBox LPWSTRtoBSTR(TagsLibrary_GetTag(Tags, StrPtr("TITLE"), ttAutomatic))
        TagsLibrary_GetAudioAttributes Tags, atAutomatic, VarPtr(TagAtts)
        MsgBox LPWSTRtoBSTR(TagAtts.PlayTime)
        TagsLibrary_Free Tags
    The first part to get any tag name Artist - Title etc works. The GetAudioAttributes does not work. I have queried the author, but he says it works fine but that he only knows delphi and not VB. A pointer to the UDT is supposed to be sent in the call, which is what I think (until you correct me) I have done.

    Steve.

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Need help getting a pointer to UDT

    (I knew you'd find another bug. Sorry, I didn't have enough time to fix all the Declares. )



    The problem with your current code is that you are passing a pointer to the return value of VarPtr, which is itself also a pointer.

    There are 2 ways of rectifying that TagsLibrary_GetAudioAttributes API declaration - either change how the Attributes parameter is passed or change its data type:

    Code:
    ... Declare Function TagsLibrary_GetAudioAttributes ... , ByVal Attributes As Long) ...
    
    TagsLibrary_GetAudioAttributes Tags, atAutomatic, VarPtr(TagAtts)
    
    
    
    ... Declare Function TagsLibrary_GetAudioAttributes ... , ByRef Attributes As TAudioAttributes) ...
    
    TagsLibrary_GetAudioAttributes Tags, atAutomatic, TagAtts
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Need help getting a pointer to UDT

    There are two ways to fix the problem:

    1) Change the function declaration to this:

    Code:
    Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByVal Attributes As Long) As Long
    Right now, the Attributes parameter is declared ByRef, so VB automatically takes whatever variable you pass to that parameter, and sends a pointer in its place. So when you use:

    Code:
    TagsLibrary_GetAudioAttributes Tags, atAutomatic, VarPtr(TagAtts)
    VB is sending a pointer to a pointer to TagAtts.

    2) Change the function declaration to this:

    Code:
    Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByRef Attributes As TAudioAttributes) As Long
    ...then change all function references to be:

    Code:
    TagsLibrary_GetAudioAttributes Tags, atAutomatic, TagAtts
    VB will automatically supply a pointer to TagAtts in this case, as the Attributes parameter is declared ByRef. You don't need to use VarPtr if you declare it like this.

    HTH

    Edit: ninja'd by Bonnie!
    Check out PhotoDemon, a pro-grade photo editor written completely in VB6. (Full source available at GitHub.)

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    @Bonnie, absolutely no need for apology. I am very grateful for your help. @Tanner, many thanks too.

    I have tried both methods whilst still successfully getting 'Artist' 'Title' etc to prove the function is being sent the correct filename. If I do not use LPWSTRtoBSTR, then the msgbox contains 0. If I do use it then I get a blank msgbox.

    Code:
    MsgBox TagAtts.PlayTime
    I don't know if this extract from the ReadMe.txt is useful to you.

    Code:
    TagsLibrary_GetAudioAttributes(Tags: HTags; AudioType: TAudioType; Attributes: Pointer): Pointer;
    	Get source audio file's attributes.
    	Supported 'AudioTypes's:
    	    atAutomatic: returns 'TAudioAttributes' structure (automatic source detection) in 'Attributes'
    	    atFlac: returns a 'TFlacAudioAttributes' structure (Flac and Ogg Flac) in 'Attributes'
    	    atMPEG: returns a 'TMPEGAudioAttributes' structure (.mp3, .mp2, .mp1, .mpa) in 'Attributes'
    	    atDSDDSF: returns a 'TDSFAudioAttributes' structure (DSD .dsf) in 'Attributes'
                      atMP4: returns a 'TMP4AudioAttributes' structure (MP4 audio) in 'Attributes'
    	    atOpus: returns a 'TOpusAudioAttributes' structure (Opus) in 'Attributes'
    	    atVorbis: returns a 'TVorbisAudioAttributes' structure (Vorbis) in 'Attributes'
    	    atWAV: returns a 'TWAVEAudioAttributes' structure (WAV and RF64) in 'Attributes'
    	    atAIFF: returns a 'TAIFFAudioAttributes' structure (AIFF and AIFC) in 'Attributes'
    	    atWMA: returns a 'TWMAAudioAttributes' structure (WMA) in 'Attributes'

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    Sorry for my bad manners in bumping - but I still need help/guidance if possible.

    Regards - Steve.

  6. #6
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,560

    Re: Need help getting a pointer to UDT

    Is it just me seeing in the OP that he uses ttAutomatic twice, in the next line he uses atAutomatic?
    And what are the values of these constants(?) (seem to be Enums).
    Is it supposed to be two different variables?
    Just seeing that code-snippet both should be zero
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

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

    Re: Need help getting a pointer to UDT

    Quote Originally Posted by Steve Grant View Post
    I have tried both methods whilst still successfully getting 'Artist' 'Title' etc to prove the function is being sent the correct filename. If I do not use LPWSTRtoBSTR, then the msgbox contains 0. If I do use it then I get a blank msgbox.
    You would NOT use LPWSTRtoBSTR. That function's purpose is to convert a string pointer to a VB string. The PlayTime member of your UDT is a Double not a string pointer. The function may be working correctly? Maybe the PlayTime 'tag/info' doesn't exist in the file?
    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}

  8. #8
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Need help getting a pointer to UDT

    As mentioned already, the TAudioAttributes' PlayTime member is not a pointer to a Unicode string or to any other data and therefore shouldn't be passed to the LPWSTRtoBSTR function. In the original Delphi source, it was typed as Double. As far as I can tell, the Double data type in Delphi is equivalent to, or at least the same size as, VB6's Double data type.

    I tried your test code with some sample .WAV files I got from a web search and it appears successful in getting some of the attributes correctly. However, it returned random values for the PlayTime and SampleCount attributes each time I ran your code. Sorry, but I have no idea what's going on there...
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    He sent me an .exe to actually use on the test file and it works fine. Here is his Delphi code

    Code:
    var
        AudioAttributes: TAudioAttributes;
    begin
        Memo1.Clear;
        TagsLibrary_Load(Tags, PWideChar(Edit1.Text), ttAutomatic, True);
        //* Get audio attributes
        TagsLibrary_GetAudioAttributes(Tags, atAutomatic, @AudioAttributes);
        Memo1.Lines.Append('Channels: ' + IntToStr(AudioAttributes.Channels));
        Memo1.Lines.Append('SamplesPerSec: ' + IntToStr(AudioAttributes.SamplesPerSec));
        Memo1.Lines.Append('BitsPerSample: ' + IntToStr(AudioAttributes.BitsPerSample));
        Memo1.Lines.Append('PlayTime: ' + FloatToStr(AudioAttributes.PlayTime));
        Memo1.Lines.Append('SampleCount: ' + IntToStr(AudioAttributes.SampleCount));
        Memo1.Lines.Append('BitRate: ' + IntToStr(AudioAttributes.BitRate));
    For Zvoni here is the UDT.

    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
    
    Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal tags As Long, ByVal AudioType As TAudioType, ByVal Attributes As Long) As Long
    End Type
    Here is my calling code:
    Code:
    Dim tags As Long,TagAtts As TAudioAttributes
        tags = TagsLibrary_Create
        TagsLibrary_Load tags, StrPtr(FileName), ttAutomatic, True
        TagsLibrary_GetAudioAttributes tags, atAutomatic, VarPtr(TagAtts)
        MsgBox CStr(TagAtts.PlayTime)
    This returns with this:Attachment 123603

    ttAutomatic is used for the tags. atAutomatic is used for the attributes. If your change the declare to ByRef Attributes as TAudioAttributes then this restricts the user to just TAudioAttributes. There are many others for different audio formats. I figured if I could at least get it working with atAutomatic, that would be a great start. The ByRef method doesn't work either.

    Many thanks to you both for your help.

    Steve.Attachment 123607

  10. #10
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,560

    Re: Need help getting a pointer to UDT

    Have you tried forcing your call with ByRef instead of VarPtr?

    EDIT: the function returns a long. Have you tried reading that result (Error-code?)
    Last edited by Zvoni; Feb 10th, 2015 at 11:22 AM.
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    I have just tested then function return and it is 0. Is that good or bad?

    I cannot get the syntax right for forcing a ByRef, the line below is red!

    Code:
    Result = TagsLibrary_GetAudioAttributes(tags, atAutomatic, ByRef(TagAtts as TAudioAttributes))

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

    Re: Need help getting a pointer to UDT

    Bonnie & Steve.

    Have you verified this structure is correct, specifically the blue-highlighted line:
    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
    I ask because of what Steve posted just a bit ago...
    Code:
    Memo1.Lines.Append('SampleCount: ' + IntToStr(AudioAttributes.SampleCount))
    The dll author is converting INT to string, not an 8-byte value. So if SampleCount in the UDT should be Long vs Currency, this is a matter of correctness and may not fix the problem. Possibly there are one or two more structures mis-defined that can be causing a snowball effect here?

    If this is the case, then this change is needed. If it isn't the case and change is made, a crash is likely
    Code:
     SampleCount   As Long
    Last edited by LaVolpe; Feb 10th, 2015 at 12:00 PM.
    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}

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    Thanks Keith,

    If you think about it, there are usually 44,100 samples per second. So a long would be good for 13.5 hours. However change it long and programme crashes as soon as the function is called.

    Steve.

    P.S. What is our eqivalent of IntToStr etc?

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

    Re: Need help getting a pointer to UDT

    Quote Originally Posted by Steve Grant View Post
    P.S. What is our eqivalent of IntToStr etc?
    Within VB, CStr(AlmostAnything)
    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}

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

    Re: Need help getting a pointer to UDT

    I went back to your original posting and looked at the source & Bonnie's translation of the UDTs. I now know why it crashed... the UDT is expecting an 8-byte value & IntToString is converting an Int64. It clears it up for me. But doesn't solve your issue.

    Bottom line, I didn't see anything amiss with what Bonnie provided, except for one translation
    Code:
    === from your source
    Type TDSFAudioAttributes
        FormatVersion As Long
        FormatID As Long
        ChannelType As TDSFChannelType
        ChannelNumber As Long
        SamplingFrequency As Long
        BitsPerSample As Long
        SampleCount As Int64
        BlockSizePerChannel As Long
        PlayTime As Double
        Bitrate As Integer
    End Type
    Code:
    ===== Bonnie's translation
    Public Type TDSFAudioAttributes
        FormatVersion       As Long
        FormatID            As Long
        ChannelType         As TDSFChannelType
        ChannelNumber       As Long
        SamplingFrequency   As Long
        BitsPerSample       As Long
        BlockSizePerChannel As Long
        PlayTime            As Double
        SampleCount         As Currency
        Bitrate             As Long
    End Type
    The next to last 3 members of the UDT are not in the original order. Don't know if this is on purpose or fixed later by you & her.
    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}

  16. #16
    Addicted Member Wolfgang Enzinger's Avatar
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    151

    Re: Need help getting a pointer to UDT

    This works perfectly here:

    Code:
    Option Explicit
    
    Public Enum TAudioType
        atAutomatic
        atFlac
        atMPEG
        atDSDDSF
        atWAV
        atAIFF
        atMP4
        atOpus
        atVorbis
        atWMA
    End Enum
    
    Public Enum TTagType
        ttNone
        ttAutomatic
        ttAPEv2
        ttFlac
        ttID3v1
        ttID3v2
        ttMP4
        ttOpusVorbis
        ttWAV
        ttWMA
    End Enum
    
    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
    
    Public Declare Function TagsLibrary_Create Lib "TagsLib.dll" () As Long
    Public Declare Function TagsLibrary_Free Lib "TagsLib.dll" (ByVal Tags As Long) As Long
    Public Declare Function TagsLibrary_Load Lib "TagsLib.dll" (ByVal Tags As Long, ByVal FileName As Long, ByVal TagType As TTagType, ByVal ParseTags As Long) As Long
    Public Declare Function TagsLibrary_GetAudioAttributes Lib "TagsLib.dll" (ByVal Tags As Long, ByVal AudioType As TAudioType, ByRef Attributes As Long) As Long
    Public Declare Function TagsLibrary_GetTag Lib "TagsLib.dll" (ByVal Tags As Long, ByVal Name As Long, ByVal TagType As TTagType) As Long
    
    Private Declare Function SysReAllocString Lib "oleaut32.dll" (ByVal pBSTR As Long, Optional ByVal pszStrPtr As Long) As Long
    
    Public Function LPWSTRtoBSTR(ByVal lpwsz As Long) As String
        ' Input:  a valid LPWSTR pointer lpwsz
        ' Return: a BSTR with the same character array
        ' Copy string from pointer
        SysReAllocString VarPtr(LPWSTRtoBSTR), lpwsz
    End Function
    
    Sub Main()
    Dim Tags As Long, TagAtts As TAudioAttributes
        Tags = TagsLibrary_Create
        TagsLibrary_Load Tags, StrPtr("C:\Users\Public\Music\Sample Music\kalimba.mp3"), ttAutomatic, True
        MsgBox LPWSTRtoBSTR(TagsLibrary_GetTag(Tags, StrPtr("TITLE"), ttAutomatic))
        TagsLibrary_GetAudioAttributes Tags, atAutomatic, VarPtr(TagAtts)
        MsgBox CStr(TagAtts.PlayTime \ 60) & ":" & CStr(TagAtts.PlayTime Mod 60)
        TagsLibrary_Free Tags
    End Sub
    Does that work for you, too?

    Wolfgang

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    Hi Wolfgang, I put your version of the wrapper into my programme and still ended up with either nothing or zero's. This made me wonder if there was some conflict between the two. So I started a fresh VB session and put your code as is into a module and guess what - - - it worked! I thought that all the Declares being Public may be a problem, so I changed them all to Private. No luck. I find it strange that I can get the metadata ok but not the attributes. One last question for everyone; when I have seen this kind of thing before, it has always been in a Class Module - would that be likely to improve things here?

    Thanks everyone - really thank you.

    Steve.

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

    Re: Need help getting a pointer to UDT

    Class, form, module, no difference regarding declarations (other than availability to other parts of your app).

    My guess is that you do not have one or more of the DLL functions declared correctly and/or are passing the structure the wrong way, either ByVal when ByRef is expected or vice versa. Since it worked perfectly in one case and not the other, suggest carefully looking at each line of code and compare it to yours. You should spot at least one instance where you have a ByRef or ByVal used incorrectly.
    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}

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    Hi Keith, you forget I copied Wolfgang's code in without changes including his calls. Within my programme nothing - exact same code in a fresh start of VB and it works.

    Now because of that I have spent the time since my last post going through the Declares & Types/UDT's taking out what I thought I wouldn't need and it started to work. I didn't expect that so I have not done it forensically. So the declares etc that remain are untouched and obviously the calls are the same, what could have happened? Moreover my programme has been rock solid until I started playing with this code late last week. Then, as you know, it was very slightly flakey. Now it's back to being solid again. What do you think??

    Best Regards - Steve.

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

    Re: Need help getting a pointer to UDT

    Steve, I don't believe in gremlins. Simply what I think is that your code compared to Wolfgang's wasn't exactly the same as you might have thought. Can't tell you how many times I've tried to troubleshoot something and changed just a few lines, over & over again, and again, & at some time forgetting to change it back after I've eliminated it from being the problem. And that forgetful moment ultimately ended up being another 'bug', but that one was self-introduced.

    Anyway, glad you got it working. I'd follow up on post #15 though, just to ensure your UDTs are what they should be.
    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}

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    Well you and I live in the real world and although I did do just a cut and paste, you can't go through life without spilling a little coffee. I would guess that one of the declares that I have removed was wrong and went un-noticed. So - a declare/UDT that is not quite right but not, at this time anyway, called. Can it make things just a little flakey? I am an old retiree now and I thank you and all the good people her for you expertise and help.

    Regards - Steve.

  22. #22
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Need help getting a pointer to UDT

    Quote Originally Posted by LaVolpe View Post
    Bottom line, I didn't see anything amiss with what Bonnie provided, except for one translation
    . . .
    The next to last 3 members of the UDT are not in the original order. Don't know if this is on purpose or fixed later by you & her.
    In the original TagsLibraryDefs.pas Delphi unit, the TDSFAudioAttributes record was declared as:

    Code:
    type
        PDSFAudioAttributes = ^TDSFAudioAttributes;
        TDSFAudioAttributes = record
            FormatVersion: DWord;
            FormatID: DWord;
            ChannelType: TDSFChannelType;
            ChannelNumber: DWord;
            SamplingFrequency: DWord;
            BitsPerSample: DWord;
            BlockSizePerChannel: DWord;
            PlayTime: Double;
            SampleCount: UInt64;
            Bitrate: Integer;
        end;
    Meanwhile, in the accompanying TagsLibraryDefs.h C++ header file, the TDSFAudioAttributes structure was declared as:

    Code:
    typedef struct {
        DWORD FormatVersion;
        DWORD FormatID;
        TDSFChannelType ChannelType;
        DWORD ChannelNumber;
        DWORD SamplingFrequency;
        DWORD BitsPerSample;
        QWORD SampleCount;
        DWORD BlockSizePerChannel;
        double PlayTime;
        int Bitrate;
    } *PTDSFAudioAttributes, TDSFAudioAttributes;
    Since the author wrote the DLL in Delphi, I decided to "fix" the VB6 module by following his Delphi declaration. I haven't tried verifying if it works correctly, though.

    Steve, you might want to contact the author of that DLL again regarding this matter.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    559

    Re: Need help getting a pointer to UDT

    Ok Bonnie - Will do.

    Steve.

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