Hello.
Recently I started working with data transfer channels, well, those that are NamedPipe.
The functions of writing and reading into the channel, if we consider the very basis, look like this:
WriteFile(HANDLE hFile, LPVOID lpBuffer, ... ); ReadFile(HANDLE hFile, LPVOID lpBuffer, ... );
With the first parameter, everything is clear, this is the channel to which we are writing, but here is the second. The second parameter of type LPVOID
judging from the description in Windows Data Types is a pointer to any type.
However, it is impossible to write anything to the channel except char
(as well as reading), the compiler says that it cannot convert, say, int
to LPVOID
.
The question is how to work with LPVOID
? Maybe it is necessary to translate the int into it or something else? And why then the compiler does not swear to char
? (Only if this cahr
declared like this: char *X = new char[const];
)
Another question: You can write to the stream of any type. How to read from a stream to a variable of any type? Nothing happens, only in char
it is possible, which is declared via new char
(the compiler skips, but when reading, error 998 Invalid access to memory location
occurs.)