Posts Tagged ‘wininet’

Programmatically making an Internet connection in Windows Mobile in C++

Tuesday, April 29th, 2008

Although a lot of people seem to be finding my Twitter widget for Windows Mobile useful, it seems that there are also a few people who noticed that it was hacked together in a few hours overnight!

One of the more noticed issues was the fact that the widget reused the mobile’s existing Internet connection.

It was described in emails such as:

Some times I have to invoke a data session with PIE or another networked app before it will let me send a twit. Anyway to make it start it’s own network session if one doesn’t already exist?

and in tweets such as

ooh i'm liking cetwit. But not you, twittoday

oh and a side note to data apps everywhere: if you want a connection, REQUEST IT YOURSELF. I have better things to do than holding your hand

The issue is that when you use the web services APIs, this is all handled for you. But I rolled my own HTTP POST code using the wininet API. And these low-level calls aren’t so helpful.

It wasn’t a problem for me, because my phone is always connected anyway. But enough people have mentioned it, so I figured it was worth looking into!

If anyone is interested in how you start a connection programmatically in C++, read on.

(more…)