Announcement

Collapse
No announcement yet.

Error with DLL while calling from VB.

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

  • Error with DLL while calling from VB.

    Here's what I'm using:
    VB 6.0 Enterprise
    PB/DLL 6.0
    Windows 2000 (NTFS not FAT32)

    When I call this certian DLL I made VB6.EXE gets an Application Error:

    The instruction at "0x03cf109b" referenced memory at "0x00000050". The memory could not be "read".
    Any ideas?

    ------------------
    Thank you,
    Ryan M. Cross
    Webmaster FlexiFish Inc. UK
    Likuid Creations Inc.

    [This message has been edited by RyanCross (edited October 09, 2000).]
    Thank you,
    Ryan M. Cross

  • #2
    Ryan,

    Could you be more specific? Which DLL are you trying to call? Is it a PB-created DLL, or is it a Win32 system DLL? In either case, what does the method signature look like? How are you declaring the API in VB?

    Thanks,

    Jason

    ------------------

    Comment


    • #3
      It's a PB made DLL it's made to get the active IP. The declare I'm using is:
      Code:
      Declare Function ActiveIP Lib "C:\IPROTO.DLL" Alias "ACTIVEIP" (serverIP$, ByVal prt&) As String
      And here's the code in the DLL:
      Code:
      #COMPILE DLL
      #DIM NONE
      
      UNION in_addr
            s_addr AS LONG
            s AS STRING * 4
      END UNION
      
      TYPE sockaddr_in
           sin_family AS WORD
           sin_port AS WORD
           sin_addr AS in_addr
           sin_zero AS STRING * 8
      END TYPE
      
      
      DECLARE FUNCTION getsockname LIB "wsock32.dll" ALIAS "getsockname" (BYVAL s AS LONG, sname AS sockaddr_in, namelen AS LONG) AS LONG
      DECLARE FUNCTION TcpAddr(BYVAL s AS LONG) AS LONG
      DECLARE FUNCTION FormatIP(RawAddr AS LONG) AS STRING
      
      FUNCTION ActiveIP(serverIP AS STRING, prt AS LONG) EXPORT AS STRING
      hSocket& = FREEFILE
      TCP OPEN PORT prt AT serverIP AS hSocket& TIMEOUT 10
      FUNCTION = FormatIP(TcpAddr(hSocket&))
      CLOSE hSocket&
      END FUNCTION
      
      
      FUNCTION TcpAddr(BYVAL s AS LONG) AS LONG
         LOCAL sa AS sockaddr_in
         LOCAL l  AS LONG
         LOCAL x AS LONG
         s = FILEATTR(s,2)
         l = SIZEOF(sa)
         IF getsockname(s, sa, l) = 0 THEN
            x = sa.sin_addr.s_addr
            FUNCTION = sa.sin_addr.s_addr
         END IF
      END FUNCTION
      
      FUNCTION FormatIP(RawAddr AS LONG) AS STRING
      
         DIM sAddr AS STRING
      
         sAddr = MKL$(RawAddr)
         FUNCTION = FORMAT$(ASC(MID$(sAddr, 1, 1))) + "." + _
                    FORMAT$(ASC(MID$(sAddr, 2, 1))) + "." + _
                    FORMAT$(ASC(MID$(sAddr, 3, 1))) + "." + _
                    FORMAT$(ASC(MID$(sAddr, 4, 1)))
      END FUNCTION
      Thanks.


      ------------------
      Thank you,
      Ryan M. Cross
      Webmaster FlexiFish Inc. UK
      Likuid Creations Inc.
      Thank you,
      Ryan M. Cross

      Comment


      • #4
        You've declared ActiveIP with BYVAL prt&, but your DLL code is
        expecting to see BYREF prt&. You need to make them match.

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          Thanks I'll try it.

          ------------------
          Thank you,
          Ryan M. Cross
          Webmaster FlexiFish Inc. UK
          Likuid Creations Inc.
          Thank you,
          Ryan M. Cross

          Comment


          • #6
            Thanks a lot Tim, you're the man!

            ------------------
            Thank you,
            Ryan M. Cross
            Webmaster FlexiFish Inc. UK
            Likuid Creations Inc.
            Thank you,
            Ryan M. Cross

            Comment

            Working...
            X