Hello all.

I would like to use the Connection Manager API to see what
connection(s) are currently established. As far as I've seen, I can
use ConnMgrConnectionStatus to get the information. However, that
function requires a HANDLE to that connection, which is acquired via
ConnMgrEstablishConnectionSync.

Now, if I enumerate the connections, then get the handle in order to
check status, does that mean that there will be a connection attempt
request for each connection?

Is there a way to get the connection status without issuing a
connection request (sync or async)? I'm thinking one workaround could
be to use a short (100-500ms) timeout in EstablishConnectionSync, so if
the connection is already connected, it will immediately return.
Otherwise (if not connected), it will "immediately" timeout. Sounds
kind of hack-ish to me, though.

In case platform is relevant here, I intend to target WM 2003 and
higher.

Thanks in advance!

-Carlos

Re: ConnectionManager and Handle-less Connection Status by Peter

Peter
Wed Feb 22 09:21:01 CST 2006

If you call ConnMgrEstablishConnection with the lowest possible priority
(CONNMGR_PRIORITY_LOWBKGND) it should never attempt to connect and only use
a connection which another higher priority app has requested. also check out
the bDisabled member as this seems to indicate that also it checks status
but doesn't create a connection.

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

"Carlos" <c_soltero_pales@hotmail.com> wrote in message
news:1140618745.380179.177630@o13g2000cwo.googlegroups.com...
> Hello all.
>
> I would like to use the Connection Manager API to see what
> connection(s) are currently established. As far as I've seen, I can
> use ConnMgrConnectionStatus to get the information. However, that
> function requires a HANDLE to that connection, which is acquired via
> ConnMgrEstablishConnectionSync.
>
> Now, if I enumerate the connections, then get the handle in order to
> check status, does that mean that there will be a connection attempt
> request for each connection?
>
> Is there a way to get the connection status without issuing a
> connection request (sync or async)? I'm thinking one workaround could
> be to use a short (100-500ms) timeout in EstablishConnectionSync, so if
> the connection is already connected, it will immediately return.
> Otherwise (if not connected), it will "immediately" timeout. Sounds
> kind of hack-ish to me, though.
>
> In case platform is relevant here, I intend to target WM 2003 and
> higher.
>
> Thanks in advance!
>
> -Carlos
>



Re: ConnectionManager and Handle-less Connection Status by Carlos

Carlos
Fri Feb 24 11:58:53 CST 2006

Hi Peter, and thanks very much for the response.

Setting bDisabled helps in that a connection is not attempted, but the
status returned is either NOPATHTODESTINATION or DISABLED. So, that
tells me whether or not a connection can be made, not necessarily the
current status.

The key tip was the lower priority value you mentioned. Now I'm using
the code below and it seems to work as I intended.

...
connInfo.dwPriority = CONNMGR_PRIORITY_LOWBKGND;
connInfo.bDisabled = FALSE;

// Get connection handle
HRESULT hr = ConnMgrEstablishConnection(&connInfo, &hConn);

DWORD connStatus = CONNMGR_STATUS_UNKNOWN;

// Retrieve connection status
while (connStatus == CONNMGR_STATUS_UNKNOWN) {
hr = ConnMgrConnectionStatus(hConn, &connStatus);
Sleep(100);
}

hr = ConnMgrReleaseConnection(hConn, 0);

if (connStatus == CONNMGR_STATUS_CONNECTED)
{
// Connection found
}