[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 928
  • Last Modified:

How can i list or detect active mailslots?

Hello,
I'm trying to detect active mailslots running on system.I normally can detect if i know the exact name of mailslot that active but if its having some randomly generated characters to extend that name i can't detect it.
So I'm curious if is there a way to detect or list active mailslots running on the system?
Regards
0
juberti
Asked:
juberti
  • 4
  • 2
1 Solution
 
tampnicCommented:
I am assuming we are talking about Windows here. Don't know if mailslots are used on *NIX systems.

Get a copy of "process explorer"  from sysinternals http://www.sysinternals.com/Utilities/ProcessExplorer.html

Start PE and search (File Handle) for \Device\Mailslot:

Alternatively, if you need to do this from code you can enumerate the files in the \\.\mailslot directory.

Cheers,
  Chris
0
 
tampnicCommented:
Corrected link for Process Explorer - the one above is dead

http://technet.microsoft.com/en-us/sysinternals/bb896653

Cheers,
   Chris
0
 
jubertiAuthor Commented:
Hello tampnic,
I'm trying to add such check for my local security program which im using for my own usage, So basically i need a code sample for it:)
Thanks for your help.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
tampnicCommented:
This code attached is from the "Using Mailslots for Interprocess Communication" article on CodeProject. http://www.codeproject.com/KB/cpp/mailslots.aspx

In the mailslot enumerator project here is the function used to populate the list of mailslots currently open. Its using a CFileFind class from MFC but is easily modified to use standard win32 calls such as FindFirstFile() and FindNextFile() if you don't want MFC.

 
void CEnumerateMailSlotsDlg::OnBnClickedRefresh()
{
	m_list.ResetContent();

	CFileFind ff;
	BOOL	  bWorking = ff.FindFile(_T("\\\\.\\mailslot\\*.*"));

	while (bWorking)
	{
		bWorking = ff.FindNextFile();
		m_list.AddString(ff.GetFilePath());
	}
}

Open in new window


Cheers,
  Chris
0
 
jubertiAuthor Commented:
Hello,
Somehow it doesnt list or detect mailslots in vista :/, I dunno why or whats wrong...
Regards
0
 
tampnicCommented:
You might need elevated privileges to view the mailslots. Try altering the option Linker-> Manifest File -> UAC Execution Level to "requireAdministator". This will cause your program to ask for elevated privileges before executing.

Cheers,
  Chris
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now