Developer forums (C::B DEVELOPMENT STRICTLY!) > Development
Non-DDE IPC?
DJMaze:
Ehm i was wondering why use shared memory when the message handler failed?
It is pretty easy to create a message queue with mutexes.
--- Code: ---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);
}
--- End code ---
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()
TheNullinator:
Hi,
Sorry for disappearing for a month and a bit. I had a few health issues.
I rewrote most of the code this morning and last night and fixed a few good bugs in the process. Here is a list of current issues I know about with the new code.
* Sometimes the active window is not registered correctly as the current window so files are opened in the previously active window.
* The window is never brought to the foreground after a file has been opened under Windows ME -- but the taskbar button flashes.
* Sometimes under Windows ME a message about the system being low on memory is displayed after during the opening of a selection of about 30 files or so. Also happens on repeated openings of a selection of about 8 files. System Monitor didn't report a lack of memory. :? This issue doesn't occur if you repeatedly open a single file at a time.
I have placed the IPC code in a new class in the files ipc.h and ipc.cpp. It should be easy enough to modify the code to support other operating systems.
Cheers
[attachment deleted by admin]
TheNullinator:
@DJMaze
I had considered taking that approach earlier on, but it seemed to me, personally, a tad untidy after I'd implemented a bit of it, though that may have just been my way of going about it. I think Thomas' idea of using shared memory is very clean and probably easier to port.
Cheers
Navigation
[0] Message Index
[*] Previous page
Go to full version