Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Jun : Mailslot messages crippled on reading
| Subject: | Mailslot messages crippled on reading |
| Posted by: | "Danny Strümpel" (danny..@invalid) |
| Date: | Wed, 18 Jun 2008 21:04:06 |
Hello,
I have some problems with implementing mailslots.
The mailslot is created properly, gets connected to properly, also
writing to and reading from the mailslot is possible (i.e., all Win32
functions return without an error).
When reading, I can't get the original message that has been sent to the
Server application. Instead, I get some crippled data, like 'Â… Œö '.
The (current) code for reading is (cut to the essential):
var
msgSize, msgCount, bytesRead: DWORD;
msg: TShortString;
begin
GetMailslotInfo(hSlot, nil, msgSize, @msgCount, nil);
SetLength(msg, msgSize);
ReadFile(hSlot, msg, msgSize, bytesRead, nil);
end;
The actual code can be downloaded at borland.public.attachments (posting
from 06/13/2008).
What am I doing wrong?
I've tried lots of different data types for msg (PChar, array [0..1023]
of Char, string), different ways of memory allocation (SetLength, New,
GlobalAlloc), assigning a standard SecurityAttribute with and without
default SecurityDescriptor to mailslot related functions, as well as
reading from it passing an OVERLAPPED structure to ReadFile.
Btw, I'm developing under Vista, but running the test applications under
W2K gave the same results. The test applications run under the same user
account.
Thanks for any hints.
--
I doubt, therefore I am.
...und wech
Danny <dannys9 (at) gmx (dot) de