Faced a problem in the work of the VO.Console class. The Write() method does not print text to the console. With ILSpy I investigated this method, and apparently the problem is in the FileStream.Write() method (FWrite -> XSharp.IO.File.writeBuf), with the console handle argument passed to it. The handle of console in the VO.Console class is obtained as: hConOut := GetStdHandle(STD_OUTPUT_HANDLE).
There are two problems that I noticed (but maybe I overlooked or misunderstood something):
1. The XSharp.IO.File.writeBuf method receives a FileStream object from the cache (streams dictionary) by handle (findStream() method), but does not add this key to streams anywhere. But maybe I just did not understand the code.
2. The FileStream class does not work with the console handle obtained using GetStdHandle(STD_OUTPUT_HANDLE). Throws an exception. If you pass it a handle obtained, for example, from CreateFile(), then FileStream works fine.
The WriteFile() function works with the console handle without any problems:
Code: Select all
hConOut := GetStdHandle(STD_OUTPUT_HANDLE)
WriteFile(hConOut, String2Psz("abc"), 3, @nWritten, NULL)
Leonid