Announcement

Collapse
No announcement yet.

Linking PB with Vb5

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

  • Linking PB with Vb5

    I have been having trouble linking PowerBasic DLL's with VB5. Could someone give me the brief version of creating 32bit DLL's and linking them.

    Also, is it possible to link a 16bit DLL in Vb5?

    T

    -------------
    Explorations v3.0 RPG Development System
    http://www.explore-rpg.com
    Explorations v9.10 RPG Development System
    http://www.explore-rpg.com

  • #2
    Tyrone,

    suppose this is your PB function which should be exported:

    Code:
    Function pbParseCount Alias "pbParseCount" (sMain As STRING, ByVal iAny As INTEGER, _
       sPattern As STRING) Export As LONG
    
    If IsFalse(iAny) Then
       pbParseCount = ParseCount(sMain, sPattern)
    Else
       pbParseCount = ParseCount(sMain, Any sPattern)
    End If
    
    End Function
    Then your Declare in VB should look like
    Code:
    Declare Function pbParseCount Lib "SNSFUN32.DLL" (sMain As STRING, ByVal iAny As INTEGER, sPattern As STRING) As LONG
    Be warned though that if you run your App from within the VB-IDE VB sometimes doesn't find your DLL. Copy the compiled either to a directory in the PATH, or change the VB Declare to include the full pathname to the DLL, i.e.
    Code:
    Declare Function pbParseCount Lib "C:\PBDLL60\SNSFUN32.DLL" (sMain As STRING, ByVal iAny As INTEGER, sPattern As STRING) As LONG
    Someone else might be able to answer your 16bit DLL question.

    Knuth

    Comment


    • #3
      DIRECT32.DLL is included with PB/DLL for this type of purpose. It allows a 32-bit app to call a 16-bit DLL by providing the thunking mechanism. It does not work under Windows NT, and some (recent) versions of VB (ie: VB6) may cause problems with it in some circumstances.

      Check out the PBDLL\SAMPLES directory for DIRECT32.DLL and some example files.


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

      Comment


      • #4
        Man you guys are good.. I need to hang around here more often.

        T

        -------------
        Explorations v3.0 RPG Development System
        http://www.explore-rpg.com
        Explorations v9.10 RPG Development System
        http://www.explore-rpg.com

        Comment


        • #5
          I found that including a Type Library into the DLL as a resource really helps the whole linking issue with VB.

          The number of complaints(and GPFs) I've gotten from my VB users has dropped
          to almost 0.

          Jason

          Comment


          • #6
            Jason,

            Do you have an example of a Type Library resource?

            --Dave


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

            Home of the BASIC Gurus
            www.basicguru.com

            Comment


            • #7
              I do .. but, there is a link that may be helpful for examples of how
              to write type libraries and links to MSDN documentation:
              http://www.vbaccelerator.com/typelib.htm

              I'll wrap up a more complete example for anyone who wants to be mailed
              a copy.


              Comment

              Working...
              X