Results 1 to 2 of 2

Thread: Is PeekNamedPipe broken in current version of Windows?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2008
    Posts
    1,018

    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
    2,288

    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.
    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