Click here to Skip to main content
15,112,453 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Waitting on hEvent of Mailslot Pin
Victor Nijegorodov5-Apr-16 4:25
MemberVictor Nijegorodov5-Apr-16 4:25 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 8:31
MemberForNow5-Apr-16 8:31 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 13:07
MemberForNow5-Apr-16 13:07 
GeneralRe: Waitting on hEvent of Mailslot Pin
Richard Andrew x645-Apr-16 13:39
professionalRichard Andrew x645-Apr-16 13:39 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 14:21
MemberForNow5-Apr-16 14:21 
GeneralRe: Waitting on hEvent of Mailslot Pin
Richard Andrew x645-Apr-16 14:27
professionalRichard Andrew x645-Apr-16 14:27 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 14:32
MemberForNow5-Apr-16 14:32 
GeneralRe: Waitting on hEvent of Mailslot Pin
leon de boer5-Apr-16 17:33
Memberleon de boer5-Apr-16 17:33 
The WriteFile doesn't need or require an overlapped access and I would be intrigued what security attributes you are feeding in via sa. Naming the event is fine but why are you needing to provide specific security attributes are you doing something special?

The worry I gleaned was you hold the event handle in sysblk.mail are you remembering to copy the handle reference into your overlapped structure? It's sort of odd what you are doing there but not wrong so long as you remember to transfer the handle.

The usual read thread code direct from MSDN looks like
char buffer[100];
    OVERLAPPED ovlp = {0};

    // Create event in overlapped structure
    // This directly places Event handle in empty Overlapped structure
    ovlp.hEvent = CreateEvent(NULL, false, false, NULL);

    if (ovlp.hEvent == NULL) {
        // You have some error creating the event run some error code
        
    }

    DWORD read;

    do {
        ReadFile(mailslot, buffer, sizeof(buffer), &read, &ovlp);  // ovlp.handle in your case must be sysblk.mail
        buffer[read] = 0;
        WaitForSingleObject(ovlp.hEvent, INFINITE);                // you are then waiting on your event sysblk.mail 
        process_message(buffer);
    } while (strcmp(buffer, "exit"));   // <= Your exit thread condition

The write thread is create function is non overlapped
HANDLE mailslot = CreateFile("\\\\.\\mailslot\\myslot",
GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_ALWAYS,
0,
NULL);

They are the by the book MSDN examples and your code should be some extension of that process inside your sysblk code.

Also remember this sort of thing is for relatively low speed, small packet exchanges if you want to go beyond that you need to change to memory mapped files.
In vino veritas


modified 5-Apr-16 23:21pm.

QuestionHow to custmize the ribbon category at run time using MFC Pin
Ashish Ranjan Mishra4-Apr-16 7:36
MemberAshish Ranjan Mishra4-Apr-16 7:36 
SuggestionRe: How to custmize the ribbon category at run time using MFC Pin
David Crow5-Apr-16 16:50
MemberDavid Crow5-Apr-16 16:50 
Questioninput to be parsed to produce a node tree Pin
Member 124358024-Apr-16 6:45
MemberMember 124358024-Apr-16 6:45 
SuggestionRe: input to be parsed to produce a node tree Pin
Richard MacCutchan4-Apr-16 8:03
mveRichard MacCutchan4-Apr-16 8:03 
QuestionC, Win32 API: l need a help with file/data storage Pin
Member 121394424-Apr-16 5:32
MemberMember 121394424-Apr-16 5:32 
AnswerRe: C, Win32 API: l need a help with file/data storage Pin
jeron14-Apr-16 5:49
Memberjeron14-Apr-16 5:49 
QuestionRe: C, Win32 API: l need a help with file/data storage Pin
David Crow4-Apr-16 6:22
MemberDavid Crow4-Apr-16 6:22 
AnswerRe: C, Win32 API: l need a help with file/data storage Pin
Jochen Arndt4-Apr-16 6:25
professionalJochen Arndt4-Apr-16 6:25 
QuestionAn example of _tcslwr with BYTE type Pin
Member 123535314-Apr-16 1:18
MemberMember 123535314-Apr-16 1:18 
AnswerRe: An example of _tcslwr with BYTE type Pin
Jochen Arndt4-Apr-16 2:08
professionalJochen Arndt4-Apr-16 2:08 
Questionhow to access member functions and variables in another project without .lib Pin
kamal19773-Apr-16 8:53
Memberkamal19773-Apr-16 8:53 
AnswerRe: how to access member functions and variables in another project without .lib Pin
Daniel Pfeffer3-Apr-16 21:16
professionalDaniel Pfeffer3-Apr-16 21:16 
GeneralRe: how to access member functions and variables in another project without .lib Pin
kamal19774-Apr-16 13:10
Memberkamal19774-Apr-16 13:10 
AnswerRe: how to access member functions and variables in another project without .lib Pin
Richard MacCutchan3-Apr-16 22:43
mveRichard MacCutchan3-Apr-16 22:43 
GeneralRe: how to access member functions and variables in another project without .lib Pin
kamal19774-Apr-16 13:07
Memberkamal19774-Apr-16 13:07 
GeneralRe: how to access member functions and variables in another project without .lib Pin
Richard MacCutchan4-Apr-16 22:45
mveRichard MacCutchan4-Apr-16 22:45 
GeneralRe: how to access member functions and variables in another project without .lib Pin
leon de boer5-Apr-16 3:40
Memberleon de boer5-Apr-16 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.