Click here to Skip to main content
15,898,371 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionis Let Us C by Yashavant Kanetkar a good resource or a bad. Pin
Mur25017-Apr-16 5:39
Mur25017-Apr-16 5:39 
AnswerRe: is Let Us C by Yashavant Kanetkar a good resource or a bad. Pin
Richard MacCutchan7-Apr-16 7:32
mveRichard MacCutchan7-Apr-16 7:32 
AnswerRe: is Let Us C by Yashavant Kanetkar a good resource or a bad. Pin
leon de boer7-Apr-16 16:41
leon de boer7-Apr-16 16:41 
GeneralRe: is Let Us C by Yashavant Kanetkar a good resource or a bad. Pin
Mur25018-Apr-16 6:35
Mur25018-Apr-16 6:35 
AnswerRe: is Let Us C by Yashavant Kanetkar a good resource or a bad. Pin
Bram van Kampen28-Apr-16 13:39
Bram van Kampen28-Apr-16 13:39 
QuestionERROR: undefined reference to 'auxDIBImaheLoadA' Pin
Ratul Thakur7-Apr-16 5:03
Ratul Thakur7-Apr-16 5:03 
SuggestionRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
David Crow7-Apr-16 5:22
David Crow7-Apr-16 5:22 
GeneralRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
Ratul Thakur7-Apr-16 5:33
Ratul Thakur7-Apr-16 5:33 
SuggestionRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
Richard MacCutchan7-Apr-16 7:30
mveRichard MacCutchan7-Apr-16 7:30 
AnswerRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
leon de boer7-Apr-16 22:11
leon de boer7-Apr-16 22:11 
GeneralRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
leon de boer7-Apr-16 23:06
leon de boer7-Apr-16 23:06 
GeneralRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
Ratul Thakur8-Apr-16 2:28
Ratul Thakur8-Apr-16 2:28 
GeneralRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
Ratul Thakur8-Apr-16 6:57
Ratul Thakur8-Apr-16 6:57 
GeneralRe: ERROR: undefined reference to 'auxDIBImaheLoadA' Pin
leon de boer8-Apr-16 16:58
leon de boer8-Apr-16 16:58 
QuestionWaitting on hEvent of Mailslot Pin
ForNow4-Apr-16 11:03
ForNow4-Apr-16 11:03 
AnswerRe: Waitting on hEvent of Mailslot Pin
CPallini5-Apr-16 0:53
mveCPallini5-Apr-16 0:53 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 4:03
ForNow5-Apr-16 4:03 
AnswerRe: Waitting on hEvent of Mailslot Pin
Victor Nijegorodov5-Apr-16 3:25
Victor Nijegorodov5-Apr-16 3:25 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 7:31
ForNow5-Apr-16 7:31 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 12:07
ForNow5-Apr-16 12:07 
GeneralRe: Waitting on hEvent of Mailslot Pin
Richard Andrew x645-Apr-16 12:39
professionalRichard Andrew x645-Apr-16 12:39 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 13:21
ForNow5-Apr-16 13:21 
GeneralRe: Waitting on hEvent of Mailslot Pin
Richard Andrew x645-Apr-16 13:27
professionalRichard Andrew x645-Apr-16 13:27 
GeneralRe: Waitting on hEvent of Mailslot Pin
ForNow5-Apr-16 13:32
ForNow5-Apr-16 13:32 
GeneralRe: Waitting on hEvent of Mailslot Pin
leon de boer5-Apr-16 16:33
leon de boer5-Apr-16 16: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.

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.