Code for connecting wince smartphone to the Internet

Source: Internet
Author: User

1. Simulator

 

Int inetwork;
Hresult = e_fail;
DWORD dwstatus = 0;
 
// Cleanup the old connection
Destroyconnection (lpconnection );
 
// Get the right network to connect
// If (lb_err! = Inetwork)
 
Connmgr_destination_info destinfo;
 
Tint I = 0;
For (I = 0; succeeded (connmgrenumdestinations (I, & destinfo); I ++) // enumerate Access Points
{

// Actually try to establish the connection
Connmgr_connectioninfo conninfo;

Zeromemory (& conninfo, sizeof (conninfo ));
Conninfo. cbsize = sizeof (conninfo );
Conninfo. dwparams = connmgr_param_guiddestnet;
Conninfo. dwpriority = connmgr_priority_userbackground;
Conninfo. guiddestnet = destinfo. guid;
Conninfo. hwnd = hdlg;
Conninfo. umsg = lpconnection-> wm_cmevent;

Hresult = connmgrestablishconnectionsync (& conninfo, & lpconnection-> hconnection, 60000, & dwstatus );

// Check to see if the attempt failed
If (succeeded (hresult ))
{
Break;


}

}

Return hresult;

2. Mobile phone

 

Handle hconection;
DWORD dwstatus;
Connmgr_connectioninfo sconinfo;
Memset (& sconinfo, 0, sizeof (connmgr_connectioninfo ));

Connmgr_destination_info destinfo;
 
Tint I = 0;
For (I = 0; succeeded (connmgrenumdestinations (I, & destinfo); I ++)
{

 
Sconinfo. cbsize = sizeof (connmgr_connectioninfo );
Sconinfo. dwparams = connmgr_param_guiddestnet;
Sconinfo. dwpriority = connmgr_priority_userinteractive;
Sconinfo. dwflags = connmgr_flag_proxy_http
| Connmgr_flag_proxy_wap
| Connmgr_flag_proxy_socks4
| Connmgr_flag_proxy_socks5;

Sconinfo. bexclusive = false;
Sconinfo. bdisabled = false;

Sconinfo. guiddestnet = destinfo. guid; // iid_destnetinternet

If (succeeded (connmgrestablishconnectionsync (& sconinfo, & hconection, 60000, & dwstatus )))
{
Return true;
}
}
 
Return false;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.