IPC Queue Existing ?

c++ / delphi package - dll injection and api hooking
Post Reply
npadbidri
Posts: 5
Joined: Sun Feb 11, 2007 10:28 am

IPC Queue Existing ?

Post by npadbidri »

Hi,

I am using the madshi IPC Queue functionality. This queue is being shared across processes.

My project need is that I want to know if the IPC queue has been created by another process. Is there such a API that help me know if the queue is already existing ?

Thanks,
- Nilesh Padbidri.
iconic
Site Admin
Posts: 1065
Joined: Wed Jun 08, 2005 5:08 am

Post by iconic »

Only 1 IPC queue can exist in system at 1 time by design of Madshi so each queue name must be unique. If you need to know if the IPC is already up the easiest way is to try and create the queue with the same name as the queue you are checking. If project1.exe creates an ipc queue with name of "test" and project2.exe needs to know if queue is already up (project2.exe could be a DLL of course too and do this which would also work just fine) you could just try and recreate the same queue to check.

Code: Select all

 if not BOOL(CreateIPCQueue('Test', Callback)) then
   MessageBox(0, 'Already Up', nil, MB_OK)
 else
   MessageBox(0, 'Not Up', 'Created Queue Successfully', MB_OK);
--Iconic
npadbidri
Posts: 5
Joined: Sun Feb 11, 2007 10:28 am

IPC Queue Existing ?

Post by npadbidri »

Thanks, the solution does work.

But we are also assuming that the MADSHI library will never fail to create a queue, right ?

Thanks,
- Nilesh Padbidri.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: IPC Queue Existing ?

Post by madshi »

npadbidri wrote:But we are also assuming that the MADSHI library will never fail to create a queue, right ?
Heh... :)

You're right, of course there could be another reason why CreateIpcQueue could fail. What I can do is to make sure that GetLastError will return a good value when CreateIpcQueue fails. Currently you can not rely on GetLastError when CreateIpcQueue failed. But I think with the next build I'll return ERROR_ALREADY_EXISTS if the queue already existed and some other error otherwise. Would that help?
npadbidri
Posts: 5
Joined: Sun Feb 11, 2007 10:28 am

Re: IPC Queue Existing ?

Post by npadbidri »

Yes that would be useful. But I think it would be useful to have a explicit function to check if a queue is existing.

The reason for a separate function is because to CreateIpcQueue if I pass NULL as the callback it returns failure. So it would be good to have a independent function for the same.
Post Reply