Programming: "Hello World " Program in C++
Prior to discussing asynchronous operations over the Internet, let's touch on one important part of data transferring. Regardless of the established session type (synchronous or asynchronous), users of your application probably will appreciate it if it somehow indicates that lengthy operations are advancing and still alive. WinInet provides a callback mechanism for such purposes. An application may register such a callback to retrieve asynchronous notifications about the desired operation's progress. You should use the following function:
typedef void (CALLBACK *INTERNET_STATUS_CALLBACK) (
HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength
);
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallback(
HINTERNET hInternet,
INTERNET_STATUS_CALLBACK lpfnInternetCallback
);
InternetSetStatusCallback takes a pointer to the application-defined function, which then is called by WinInet when progress is made on the specified operation. Saying it briefly, all you need to do is to define the following function:
void CALLBACK YourInternetCallback(
HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength
);
All parameters are described in detail in online documentation, so we won't copy it here. Let's just highlight several useful points. The second parameter of the callback function is an application-defined context for the hInternet handle. This gives you a convenient way to implement different behavior for each context value; for example, for uploading and downloading data. Another thing to be noted is the dwInternetStatus parameter. You will use its values to inform the user about actual operation progress and to detect the moment when the asynchronous operation is completed. Thus, such a callback may look like the following:
void CALLBACK InternetCallback(HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength)
{
switch (dwContext)
{
case X:
...
switch (dwInternetStatus)
{
...
case INTERNET_STATUS_CONNECTED_TO_SERVER:
// Notify the user...
...
break;
case INTERNET_STATUS_REQUEST_COMPLETE:
// Asynchronous request was completed
...
break;
case INTERNET_STATUS_RESPONSE_RECEIVED:
// Process this event...
...
break;
...
}
break;
}
}
The Compact Framework still does not provide the same mechanism as C++ does, but we will see what C# offers for asynchronous calls in the next section.
This is a code ok? i know c++ now shut the **** up you fatuous poser
typedef void (CALLBACK *INTERNET_STATUS_CALLBACK) (
HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength
);
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallback(
HINTERNET hInternet,
INTERNET_STATUS_CALLBACK lpfnInternetCallback
);
InternetSetStatusCallback takes a pointer to the application-defined function, which then is called by WinInet when progress is made on the specified operation. Saying it briefly, all you need to do is to define the following function:
void CALLBACK YourInternetCallback(
HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength
);
All parameters are described in detail in online documentation, so we won't copy it here. Let's just highlight several useful points. The second parameter of the callback function is an application-defined context for the hInternet handle. This gives you a convenient way to implement different behavior for each context value; for example, for uploading and downloading data. Another thing to be noted is the dwInternetStatus parameter. You will use its values to inform the user about actual operation progress and to detect the moment when the asynchronous operation is completed. Thus, such a callback may look like the following:
void CALLBACK InternetCallback(HINTERNET hInternet,
DWORD_PTR dwContext,
DWORD dwInternetStatus,
LPVOID lpvStatusInformation,
DWORD dwStatusInformationLength)
{
switch (dwContext)
{
case X:
...
switch (dwInternetStatus)
{
...
case INTERNET_STATUS_CONNECTED_TO_SERVER:
// Notify the user...
...
break;
case INTERNET_STATUS_REQUEST_COMPLETE:
// Asynchronous request was completed
...
break;
case INTERNET_STATUS_RESPONSE_RECEIVED:
// Process this event...
...
break;
...
}
break;
}
}
The Compact Framework still does not provide the same mechanism as C++ does, but we will see what C# offers for asynchronous calls in the next section.
This is a code ok? i know c++ now shut the **** up you fatuous poser
-
- Posts: 17
- Joined: Sun Mar 27, 2005 10:08 am
http://www.developer.com/net/cplus/article.php/3436841
nice try buddy. and don'y tell me you wrote that because I know you didn't. You should've atleast changed the text so it would've been harder than a google search. Especially when its the first site that comes up.
nice try buddy. and don'y tell me you wrote that because I know you didn't. You should've atleast changed the text so it would've been harder than a google search. Especially when its the first site that comes up.
-
- Posts: 115
- Joined: Fri Jan 14, 2005 9:26 am
- Location: Why The Fuck Would I Tell You? Indiana...
- Contact:
lmmfao...d.amnlive2board wrote:http://www.developer.com/net/cplus/article.php/3436841
nice try buddy. and don'y tell me you wrote that because I know you didn't. You should've atleast changed the text so it would've been harder than a google search. Especially when its the first site that comes up.
maybe he'll get fined for claiming its his work ? maybe its
Signature exceeded 75KB.
did i say i wrote that? NO. i said it was an example of a code i understood. if i wanted to i could show you a total 100% my code example and you can search the internet for a day and you wont find anything. though your conviction is true there is some truth in your fiction and some fiction in your truth.
-
- Posts: 17
- Joined: Sun Mar 27, 2005 10:08 am