From: Fabio Giliberti on
const int S_OK = 0;
const uint CONNMGR_PARAM_GUIDDESTNET = 0x1;
const uint CONNMGR_FLAG_PROXY_HTTP = 0x1;
const uint CONNMGR_PRIORITY_USERINTERACTIVE = 0x08000;
const uint INFINITE = 0xffffffff;
const uint CONNMGR_STATUS_CONNECTED = 0x10;

ConnectionInfo ci = new ConnectionInfo();
uint status = 0;
IntPtr phConnection = IntPtr.Zero;

ci.cbSize = (uint)Marshal.SizeOf(ci);
// This constant is the default connection for internet destinations (in my
case it is the GPRS connection).
Guid INetGuid = new Guid("436ef144b4fb4863a0418f905a62c572");
ci.guidDestNet = INetGuid;
ci.dwParams = CONNMGR_PARAM_GUIDDESTNET;
ci.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
ci.bExclusive = 0;
ci.bDisabled = 0;
ci.hWnd = IntPtr.Zero;
ci.uMsg = 0;
ci.lParam = 0;
if (ConnMgrEstablishConnectionSync(ref ci, ref phConnection, INFINITE, ref
status) != S_OK && status != CONNMGR_STATUS_CONNECTED)
{
...
/* My instructions... */
...
if (phConnection != IntPtr.Zero)
{
ConnMgrReleaseConnection(phConnection, 0);
CloseHandle(phConnection);
}
}

The "ConnMgrEstablishConnectionSync" establish the connection correctly, I
can connect to my internet server and do my instructions.
After executing my instructions I'd like to close the connection but the
code above doesnt work...(GPRS internet connection remains active even after
10 minutes).
phConnection has a value grater than 0 and assigning to some labels a
particular value, I am sure that all this code is executed.

Is there someone can explain me why this doesnt work?

Thank you very much.


From: Yaroslav Goncharov on
It this a Windows Mobile 5 device? Take a look at
http://blogs.msdn.com/windowsmobile/archive/2006/07/14/666203.aspx ("Why
doesn't it go away?" part).

--
Yaroslav Goncharov
Spb Software House, http://spbsoftwarehouse.com
Pocket PC Developer Network, http://pocketpcdn.com


"Fabio Giliberti" <fabio(a)nuovavision.com> wrote in message
news:ZAmCg.67268$zy5.1255931(a)twister1.libero.it...
> const int S_OK = 0;
> const uint CONNMGR_PARAM_GUIDDESTNET = 0x1;
> const uint CONNMGR_FLAG_PROXY_HTTP = 0x1;
> const uint CONNMGR_PRIORITY_USERINTERACTIVE = 0x08000;
> const uint INFINITE = 0xffffffff;
> const uint CONNMGR_STATUS_CONNECTED = 0x10;
>
> ConnectionInfo ci = new ConnectionInfo();
> uint status = 0;
> IntPtr phConnection = IntPtr.Zero;
>
> ci.cbSize = (uint)Marshal.SizeOf(ci);
> // This constant is the default connection for internet destinations (in
> my case it is the GPRS connection).
> Guid INetGuid = new Guid("436ef144b4fb4863a0418f905a62c572");
> ci.guidDestNet = INetGuid;
> ci.dwParams = CONNMGR_PARAM_GUIDDESTNET;
> ci.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
> ci.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
> ci.bExclusive = 0;
> ci.bDisabled = 0;
> ci.hWnd = IntPtr.Zero;
> ci.uMsg = 0;
> ci.lParam = 0;
> if (ConnMgrEstablishConnectionSync(ref ci, ref phConnection, INFINITE, ref
> status) != S_OK && status != CONNMGR_STATUS_CONNECTED)
> {
> ...
> /* My instructions... */
> ...
> if (phConnection != IntPtr.Zero)
> {
> ConnMgrReleaseConnection(phConnection, 0);
> CloseHandle(phConnection);
> }
> }
>
> The "ConnMgrEstablishConnectionSync" establish the connection correctly, I
> can connect to my internet server and do my instructions.
> After executing my instructions I'd like to close the connection but the
> code above doesnt work...(GPRS internet connection remains active even
> after 10 minutes).
> phConnection has a value grater than 0 and assigning to some labels a
> particular value, I am sure that all this code is executed.
>
> Is there someone can explain me why this doesnt work?
>
> Thank you very much.
>


 | 
Pages: 1
Prev: Datagrid
Next: DTM_BROWSERDISPATCH not working