Announcement

Collapse
No announcement yet.

InternetReadFile

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

  • InternetReadFile

    Thanks in Advance for any help you may offer

    I am working on a function that passes GETs and POSTs via wininet.dll
    to IIS and then Recieving the results in a string
    Everything works fine in VB, however I am having a dificult time
    implementing this in PB DLL

    here is my declaration (assume hRequest is a valid connection handle)

    Declare Function InternetReadFile Lib "wininet.dll"
    Alias "InternetReadFile"
    (ByVal hFile As Long,
    ByVal sBuffer As String,
    ByVal lNumBytesToRead As Long,
    lNumberOfBytesRead As Long) As Integer

    In my Function - Navigate

    dim lRes as long
    dim sReadBuffer as string


    lRes = -1
    Do While lRes
    sReadBuffer = String$(1024, Chr$(0))
    lRes = InternetReadFile(hRequest, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
    If lNumberOfBytesRead = 0 Then
    lRes = 0
    End If
    Loop


    when InternetReadFile returns I get a True (passing) returned
    and the lNumberOfBytesRead is 325 and correct, But there is no data
    in sReadBuffer.

    Changing string declarations from string to AsciiZ causes the value
    of lNumberOfBytesRead to return 0 which is not correct.

    Any help or advice would be appreciated
    Thanks
    [email protected]




    ------------------
    Sr. Software Development Engineer and Sr. Information Security Analyst,
    CEH, Digital Forensic Examiner

  • #2
    Try the following declaration and use an ASCIIZ or
    BYVAL STRPTR(STRING) for lpBuffer

    Code:
    DECLARE FUNCTION InternetReadFile LIB "WININET.DLL" ALIAS "InternetReadFile" _
    (BYVAL hFile AS LONG, _
    lpBuffer AS ASCIIZ, _
    BYVAL dwNumberOfBytesToRead AS DWORD, _
    lpdwNumberOfBytesRead AS DWORD) AS LONG
    Cheers

    Florent

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

    Comment


    • #3
      Thank you very much
      This did work with the exception of the asciiz string, I changed
      it back to string and then it started working



      ------------------
      Sr. Software Development Engineer and Sr. Information Security Analyst,
      CEH, Digital Forensic Examiner

      Comment


      • #4
        Glad it helped. Works for me with an ASCIIZ buffer (it should
        work for you too) .

        Cheers

        Florent

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

        Comment


        • #5
          Using an ASCIIZ string could be a problem if the data is binary, since the first NUL [CHR$(0)] byte in the buffer will be taken as the end of the string by PowerBASIC's string handling functions.

          It is easy to get around this by reading the data from the ASCIIZ string storage using pointers, or PEEK$(), etc, however, using another string type should eliminate this problem.



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

          Comment

          Working...
          X