bRet=HttpSendRequest (m_hRequest, strHeader c_str (), dwHeaderSize, (LPVOID) strPostData. C_str (), dwSize);
if (! BRet)
{
Cstrings strT.
StrT. The Format (" data sent failure, error code: % d ", GetLastError ());
MessageBox (strT);
return;
}
Some client computer (such as xp) can run, but a few customer computer failure, the error code is 2, can not find a file!
Strives for the great god, give directions, where is the system library or network Settings related problem less!
CodePudding user response:
Refer to the MSDN examples
//the Open Internet session.
HINTERNET hSession=: : InternetOpen (" MSDN SurfBear ",
PRE_CONFIG_INTERNET_ACCESS,
NULL,
INTERNET_INVALID_PORT_NUMBER,
0);
//Connect to www.microsoft.com.
HINTERNET hConnect=: : InternetConnect (hSession,
"Www.microsoft.com",
INTERNET_INVALID_PORT_NUMBER,
", "
", "
INTERNET_SERVICE_HTTP,
0,
0);
//Request the file/MSDN/MSDNINFO/from the server.
HINTERNET hHttpFile=: : HttpOpenRequest (hConnect,
"GET",
"/MSDN/MSDNINFO/,"
HTTP_VERSION,
NULL,
0,
INTERNET_FLAG_DONT_CACHE,
0);
//Send the request.
BOOL bSendRequest=: : HttpSendRequest (hHttpFile, NULL, 0, 0, 0).
//Get the length of the file.
Char bufQuery [32].
DWORD dwLengthBufQuery=sizeof (bufQuery);
BOOL bQuery=: : HttpQueryInfo (hHttpFile,
HTTP_QUERY_CONTENT_LENGTH,
BufQuery,
& DwLengthBufQuery);
//the Convert length from ASCII string to a DWORD.
DWORD dwFileSize=(DWORD) atol (bufQuery);
//the Allocate a buffer for the file.
Char * buffer=new char [dwFileSize + 1];
//Read the file into the buffer.
DWORD dwBytesRead;
BOOL bRead=: : InternetReadFile (hHttpFile,
Buffer,
DwFileSize + 1,
& DwBytesRead);
//Put a zero on the end of the buffer.
Buffer [dwBytesRead]=0;
//Close all of the Internet handles.
: : InternetCloseHandle (hHttpFile);
: : InternetCloseHandle (hConnect);
: : InternetCloseHandle (hSession);
//Display the file in an edit control.
PEditCtrl - & gt; SetWindowText (buffer);
CodePudding user response:
Back upstairs, @ zgl7903In accordance with your MSDN examples, in the client computer is running to HttpSendRequest failed, GetLastError error code is 2
CodePudding user response:
Run the command line under the reset winsock tryNetsh winsock reset
CodePudding user response:
@ zgl7903Netsh winsock reset this way not line!
Key customers on a computer using Delphi program can perform Http communication
CodePudding user response:
Whether VC related library environment has a problem, your runtime library VC program together with you alsoCodePudding user response:
Relations with the environment, xp32 bit, Windows 7 64 - bit libraries have to do the difference, this have any effectCodePudding user response:
Grab a package, each in caught tool than it and see what's the difference?