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

    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.
    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.
    PeekNamedPipe Handle, ByVal 0&, 0, ByVal 0&, AmountToRead, ByVal 0&
    My command line for getting data into the StdIn pipe looks like this.

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    To the moon and then left

    Re: Is PeekNamedPipe broken in current version of Windows?

    If the function fails, the return value is zero. To get extended error information, call GetLastError.
    One System to rule them all, One IDE to find them,
    One Code 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.
    For health reasons i try to avoid reading unformatted Code

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