Ehm i was wondering why use shared memory when the message handler failed?
It is pretty easy to create a message queue with mutexes.
int main(int argc, char** argv)
{
HANDLE Mutex = CreateMutex(NULL, false, _T("CodeBlocks"));
if (GetLastError() != 0) {
HWND hwndCB = 0;
while (!hwndCB) {
hwndCB = FindWindowEx(NULL, NULL, _T("CodeBlocks"), _T("CodeBlocks"));
}
// now send the commands to the handler
SendMessage();
return 0;
} else {
CreateWindow("CodeBlocks","CodeBlocks",....);
}
// now all CB stuff
CloseHandle(Mutex);
}
The "CodeBlocks" window is invisible and receives the messages and puts each command inside a list for processing.
Shared memory in combination with a queue is also fine. For example your 64k shared memory block will be a list of strings.
char **cmd;
The first *cmd will contain the argc so that each consecutive call will add data to the end. (don't forget to lock the memory while editing it)
After that send a message to trigger the handler.
The handler will then shift the elements off the beginning of the array in combination with memmove()