Named Pipes OVERLAPPED structure - possible?

To add comments, please log in or register
terminalstat
93
terminalstat  

Hi, all.


I want my named pipes to be asynchronous. So I need to use _OVERLAPPED structure as a buffer.

here is MSDN description of process: https://msdn.microsoft.com/en-us/50f6680f-900e-4411-a849-ec9a911c9e32


My current implementation does not even compile:

//-MS Types:
#define  PVOID int
#define HANDLE int
#define ULONG_PTR long
#define DWORD int

class STRUCT_OVERLAPPED {
  ULONG_PTR Internal;
  ULONG_PTR InternalHigh;
  union DUMMYUNIONNAME{
    struct DUMMYSTRUCTNAME{
      DWORD Offset;
      DWORD OffsetHigh;
    } ;
    PVOID _Pointer;
  } ;
  HANDLE    hEvent;
};

#import "kernel32.dll"
int ConnectNamedPipe(int hNamedPipe,STRUCT_OVERLAPPED* &lpOverlapped);
#import 

with error:

'lpOverlapped' - invalid parameter for import function  NamedPipes_DLLWrapper_Async.mqh 98      56


I know that according to MQL4 Reference:

The following can't be used for parameters in imported functions:

    pointers (*);
    links to objects that contain dynamic arrays and/or pointers.

Classes, string arrays or complex objects that contain strings and/or dynamic arrays of any types cannot be passed as a parameter to functions imported from DLL.


But may be there is some kind of workaround to get it work?

PS: I know Memory mapped files, mail slots, sockets aso, but want to study exactly current implementation in academic interest, thanks

_OVERLAPPED
_OVERLAPPED
  • 2018.11.15
  • windows-sdk-content
  • docs.microsoft.com
Contains information used in asynchronous (or overlapped) input and output (I/O).
Alain Verleyen
38647
Alain Verleyen  

Yes it's possible, using a char array.

See this article.

terminalstat
93
terminalstat  
Alain Verleyen:

Yes it's possible, using a char array.

See this article.

Thank's, I'll try it!
To add comments, please log in or register