Announcement

Collapse
No announcement yet.

"GetOverlappedResultsEx"

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

  • "GetOverlappedResultsEx"

    I am working on some "HardCore" Serial Port Handling and ran into MSDN about
    "GetOverlappedResults" and it stated
    Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device. To specify a timeout interval or wait on an alertable thread, use GetOverlappedResultEx.
    So I clicked the link for "GetOverlappedResultEx" but lo and behold when I do a search ANYWHERE else (PB, Google, anything) then I get no results.
    I also get no results in PB if I search for a example or search my *.inc files for "GetOverlappedResult"

    What gives??? Does it not exist?
    I am trying to convert what MSDN shows as how to call it, but PB compiler comes back with
    Missing declaration: GETOVERLAPPEDRESULTSEX
    Upon further investigation I also find at MSDN documentation that I have long learned to not believe (Just cause they want you on a current OS and not one that was the minimal for the function to exist )
    Requirements

    Minimum supported client
    Windows 8 [desktop apps | Windows Store apps] Minimum supported server
    Windows Server 2012 [desktop apps | Windows Store apps] Header
    Ioapiset.h (include Windows.h) Library
    Kernel32.lib DLL
    Kernel32.dll
    To me then does that mean I have to create my own function prototype for both "GetOverlappedResult" and "GetOverlappedResultEx" to get this thing to work???

    While I am waiting I will go see if Jose Roca has these functions prototyped in his header files....

    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    I translated GetOverlappedResult:

    Code:
    DECLARE FUNCTION GetOverlappedResult IMPORT "KERNEL32.DLL" ALIAS "GetOverlappedResult" ( _
       BYVAL hFile AS DWORD _                               ' __in  HANDLE hFile
     , BYREF lpOverlapped AS OVERLAPPED _                   ' __in  LPOVERLAPPED lpOverlapped
     , BYREF lpNumberOfBytesTransferred AS DWORD _          ' __out LPDWORD lpNumberOfBytesTransferred
     , BYVAL bWait AS LONG _                                ' __in  BOOL bWait
     ) AS LONG                                              ' BOOL
    GetOverlappedResultEx belongs to the Windows 8 SDK. But it is easy to translate...

    Code:
    DECLARE FUNCTION GetOverlappedResultEx IMPORT "KERNEL32.DLL" ALIAS "GetOverlappedResultEx" ( _
       BYVAL hFile AS DWORD _                               ' __in  HANDLE hFile
     , BYREF lpOverlapped AS OVERLAPPED _                   ' __in  LPOVERLAPPED lpOverlapped
     , BYREF lpNumberOfBytesTransferred AS DWORD _          ' __out LPDWORD lpNumberOfBytesTransferred
     , BYVAL dwMilliseconds AS DWORD _                      ' __in  DWORD dwMilliseconds
     , BYVAL bAlertable AS LONG _                           ' __in  BOOL bAlertable
     ) AS LONG                                              ' BOOL
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Ok I got as far as declaring in my includes file
      Code:
      DECLARE FUNCTION GetOverlappedResultEx LIB "Kernel32.dll" ALIAS "GetOverlappedResultEx" _
          (hFile AS DWORD, _ 
         Over_Lapped AS OverLapped, _
         lpNumberOfBytesTransferred AS WORD, _
        dwMilliseconds AS DWORD, _
        bAlertable AS LONG) AS LONG
      and calling with
      Code:
      GetOverlappedResultEx(@Device.Wait.Port_Handle, Over_Lapped,  _
          Number_Of_Bytes_Transferred, @Device.Wait.TimeOut_Time, bAlertable)
      and it compiles but I get an error of the procedure entry point could not be found....
      Telling me that the MSDN docs in this case are CORRECT (for once) about the requirements needing Windows 8
      at M$
      Last edited by Michael Mattias; 17 Sep 2015, 09:32 AM. Reason: make readable in one screen width
      Engineer's Motto: If it aint broke take it apart and fix it

      "If at 1st you don't succeed... call it version 1.0"

      "Half of Programming is coding"....."The other 90% is DEBUGGING"

      "Document my code????" .... "WHYYY??? do you think they call it CODE? "

      Comment


      • #4
        Can't you use GetOverlappedResult()?

        For an example that uses GetOverlappedResult, see Testing for the End of a File.
        Requirements
        Windows NT/2000/XP: Included in Windows NT 3.1 and later.
        Windows 95/98/Me: Included in Windows 95 and later.
        Header: Declared in Winbase.h; include Windows.h.
        Library: Use Kernel32.lib.
        I did not try asynch I-O this way, but here's a demo using callbacks ..

        Asynchronous (Overlapped) I-O Demo

        That demo uses Asynch I-O to support multiple threads writing to the same file. I did not need to use that but I really wanted to play with Asynch I-O when I got my Win/XP system to replace my Win/98 system which does not support asynch I-O

        Insufficient Code shown to understand what you are trying to do, but you might be able to use either callbacks or a user-defined event to accomplish the same thing you are trying to do with GetOverlappedResultEx if you are running on less than Windows/8. The standard WaitForSingleObject on 'hEvent' lets you specify a timeout, or run in a separate thread context. It's a thought.

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          > then does that mean I have to create my own function prototype

          Well, unless someone does it for you, yes.

          But IMO translating MSDN documentation into PB-compatible DECLARE and CALL statements should be one of your 'base' skills for calling WinAPI or any external functions.

          YOMV. (Your opinion may vary).

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Having made the code in Post #3) 'one screen readable...'
            Code:
            WINBASEAPI BOOL WINAPI GetOverlappedResultEx(
              _In_  HANDLE       hFile,
              _In_  LPOVERLAPPED lpOverlapped,
              _Out_ LPDWORD      lpNumberOfBytesTransferred,
              _In_  DWORD        dwMilliseconds,
              _In_  BOOL         bAlertable
            );
            Your DECLARE statement ...
            Code:
            DECLARE FUNCTION GetOverlappedResultEx LIB "Kernel32.dll" ALIAS "GetOverlappedResultEx" _
                (hFile AS DWORD, _ 
               Over_Lapped AS OverLapped, _
               lpNumberOfBytesTransferred AS WORD, _
              dwMilliseconds AS DWORD, _
              bAlertable AS LONG) AS LONG
            ... is not quite correct

            hFile, dwMilliseconds and bAlertable need to be "BYVAL as {LONG|DWORD}"

            lpNumberofbytestransferred needs to be "[BYREF] AS {LONG|DWORD}"

            Maybe it's just as well it did NOT execute.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              ???
              Jose gave the right answer in post #2 above.

              Comment


              • #8
                > ??? Jose gave the right answer in post #2 above.

                Then it must be true: great minds do think alike.

                FWIW, there is no One Correct Answer ==>
                This whine's time has come June 2002

                And as you can see from the date of that post, 'No One Correct Answer' has been true for a very long time. That may sound trite, but it's an important concept.

                MCM
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Hi Cliff, have you seen this.

                  It is from 95 so won't need 8+ only stuff.
                  But maybe it is too primitive for your needs.

                  Anyway, HTH, Mike.
                  There are only two speeds for computers: fast enough, and too bloody slow.
                  And there are 10 types of programmer -- those that know binary, and those that don't.

                  Comment


                  • #10
                    ???
                    Jose gave the right answer in post #2 above.
                    How did that get in there???? until tonight my posts were back-to-back so I never saw Jose's reply

                    Mike, thanx for the link, I had seen it before and some parts are what I need. (I just could not find it again)

                    I am back to another night of research and challenging coding. Hopefully I will have some samples soon to show what I am up to and avoid the "Code not shown" syndrome.
                    Engineer's Motto: If it aint broke take it apart and fix it

                    "If at 1st you don't succeed... call it version 1.0"

                    "Half of Programming is coding"....."The other 90% is DEBUGGING"

                    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

                    Comment

                    Working...
                    X