Results 1 to 2 of 2

Thread: Is PeekNamedPipe broken in current version of Windows?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Is PeekNamedPipe broken in current version of Windows?

    In my VB6 program, I'm trying to use PeekNamedPipe to see if the StdIn pipe for my program has any currently available bytes to read, so that I can know if it's safe to call ReadFile (calling ReadFile with no bytes available causes the program to lock up and become unresponsive). But PeekNamedPipe isn't working for this now, but I thought it used to work in this exact situation. What it's doing now is ALWAYS returning 0 for the number of available bytes. My declaration looks like this.
    Code:
    Private Declare Function PeekNamedPipe Lib "kernel32.dll" (ByVal hNamedPipe As Long, ByRef lpBuffer As Any, ByVal nBufferSize As Long, ByRef lpBytesRead As Any, ByRef lpTotalBytesAvail As Long, ByRef lpBytesLeftThisMessage As Any) As Long
    My code for using it looks like this.
    Code:
    PeekNamedPipe Handle, ByVal 0&, 0, ByVal 0&, AmountToRead, ByVal 0&
    My command line for getting data into the StdIn pipe looks like this.
    Code:
    Project1.exe<test.txt

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

    Re: Is PeekNamedPipe broken in current version of Windows?

    https://docs.microsoft.com/en-us/win...-peeknamedpipe

    If the function fails, the return value is zero. To get extended error information, call GetLastError.
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE 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.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

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