Announcement

Collapse
No announcement yet.

TYPE from a DLL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • TYPE from a DLL

    I have a project in which VB will be calling a DLL.
    The DLL may have a various amount of returns in an array TYPE
    It returns fine with PB when PB calls the DLL, and again, it may be a VB issue but a return error about subscript out of range or something is occuring (I'm lacking information still)

    ie:

    mydata(1).whatever
    mydata(2).whatever
    Mydata(1).whatever2


    Etc..

    Anyway I want to return this so a VB app can call it, and maybe I am doing things right already...??

    Code:
    Type ProdInfo
         Value1                As Asciiz * 3
         Value2           As Asciiz * 25
         Value3                As Asciiz * 12
    End Type 
    
    
    Declare Function ParseEmailFile(FileSpec As Asciiz,pInfo() As ProdInfo,pInfoQty As Long) As String
    'In Winmain:
    Dim pInfo(1 to 20) as ProdInfo
    'Again, in PB/DLL it calls the DLL and returns everything correctly...Maybe it's a question of How do you call a TYPE in VB???
    Thanks!

    Scott

    -------------
    Scott Turchin




    [This message has been edited by Scott Turchin (edited February 05, 2000).]
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    it sounds like a vb-udt-alignment issue. did you review the faq on vb & pb udt's? see http://www.powerbasic.com/support/pb...hread.php?t=28

    ------------------
    lance
    powerbasic support
    mailto:[email protected][email protected]</a>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Thanks Lance,

      If I can go further onto that discussion..and it appears this may not be the preferable way to do this (Not to mention I have not used VB in almost 2 years thanks to PB/DLL

      It’s important to understand that Visual Basic only inserts padding if the next member item is too large to fit in the current DWORD. In the following case, all of the items fit properly, so no padding is required, and the same exact structure can be used with PowerBASIC (employing BYTE alignment):
      Is this going to require me to sit and determine which one is going to be larger and whether padding is going to be required?


      In the exported DLL I have the following:


      Code:
      Type ProdInfo
           Qty                As Asciiz * 3
           ProdName           As Asciiz * 25
           Amt                As Asciiz * 12
      End Type
      I suspect by what I am reading that I would have to use padding here? I would not know how to determine that ...

      Confused still..but either way, I think an array will be used instead...but for general knowledge I'd be great to understand it...

      Thanks Lance
      Scott


      [This message has been edited by Scott Turchin (edited February 06, 2000).]
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        I'm not a "VB Guy" (nor do I have VB4 installed anymore) so I'll just give you what I think will happen, so take this with a pinch of salt:

        The 1st element occupies 3 bytes, so there is a padding byte added to align the next member on a DWORD boundary. The second member occupies 25 byes, so 3 bytes of paddding are added. The last member length is a multiple of 4, so no final padding is applied.

        Therefore, in PB, the structure will be 3 + 25 + 12 = 40 bytes. In VB, it is 3 + 1 + 25 + 3 + 12 = 44 bytes.

        I hope this is correct!


        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected]su[email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X