Click here to Skip to main content
16,004,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Video Pin
J512198219-Mar-06 22:57
J512198219-Mar-06 22:57 
GeneralRe: Video Pin
Monty219-Mar-06 23:04
Monty219-Mar-06 23:04 
QuestionProcess Pin
Subramaniam s.V.19-Mar-06 22:14
Subramaniam s.V.19-Mar-06 22:14 
AnswerRe: Process Pin
Naveen19-Mar-06 23:11
Naveen19-Mar-06 23:11 
GeneralRe: Process Pin
Subramaniam s.V.19-Mar-06 23:33
Subramaniam s.V.19-Mar-06 23:33 
GeneralRe: Process Pin
Naveen19-Mar-06 23:38
Naveen19-Mar-06 23:38 
Questionplease read it:related to query to particular URL Pin
baldha rakesh19-Mar-06 21:35
baldha rakesh19-Mar-06 21:35 
AnswerRe: please read it:related to query to particular URL Pin
Monty219-Mar-06 22:20
Monty219-Mar-06 22:20 
Bankey Khandelwal wrote:
its urgent


ok here it is.
BOOL GetWebContent(LPCTSTR szURL, CString &strData)
{
	strData = "";
	
	HINTERNET hConnection = InternetOpen("Microsoft Internet Explorer",
		PRE_CONFIG_INTERNET_ACCESS,
		NULL,
		INTERNET_INVALID_PORT_NUMBER,
		0);
	
	if (hConnection == NULL)
		return FALSE;
	
    DWORD dwSize;
    CHAR szHead[] = "Accept: */*\r\n\r\n";
    char *szbuf;
    HINTERNET hConnect;
	
	if (!(hConnect = InternetOpenUrl(hConnection, 
		szURL, 
		szHead,
		lstrlen(szHead), 
		INTERNET_FLAG_DONT_CACHE, 
		0)))
    {
		InternetCloseHandle(hConnection);
        return FALSE;
    }       
	
	BOOL bReadInParts = FALSE;
	DWORD dwNumberOfBytes = 0;
	// Query the size of http file
	if (InternetQueryDataAvailable(hConnect,
		&dwNumberOfBytes,
		0,
		0)){
		if (dwNumberOfBytes < 0){
			bReadInParts = TRUE;
		}
		else{
			szbuf = new char[dwNumberOfBytes+1];
			if (!InternetReadFile(hConnect, szbuf, dwNumberOfBytes, &dwSize)){
				bReadInParts = TRUE;
			}
			if (dwSize < dwNumberOfBytes+1)
				szbuf[dwSize] = '\0';
			
			strData = szbuf;
			delete []szbuf;
		}
	}
	
	if (bReadInParts){
		// Read the file in parts
		szbuf = new char[512];
        do{
			if (!InternetReadFile (hConnect, szbuf, 512,  &dwSize)){
				return FALSE;
			}
			
			if (!dwSize)
				break;  // Condition of dwSize=0 indicate EOF. Stop.
			
			if (dwSize < 512)
				szbuf[dwSize] = '\0';
			
			strData += szbuf;
			
		} while(1);
		delete []szbuf;
	}
	
	InternetCloseHandle(hConnect);
	InternetCloseHandle(hConnection);
	
	return TRUE;
}

*sorry about the crappy formating copied from production code Smile | :)


C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
GeneralRe: please read it:related to query to particular URL Pin
baldha rakesh19-Mar-06 23:56
baldha rakesh19-Mar-06 23:56 
GeneralRe: please read it:related to query to particular URL Pin
Monty220-Mar-06 0:51
Monty220-Mar-06 0:51 
QuestionChanging an HICON's colour at runtime Pin
lastgen19-Mar-06 21:32
lastgen19-Mar-06 21:32 
AnswerRe: Changing an HICON's colour at runtime Pin
Monty219-Mar-06 21:56
Monty219-Mar-06 21:56 
GeneralRe: Changing an HICON's colour at runtime Pin
lastgen20-Mar-06 10:52
lastgen20-Mar-06 10:52 
QuestionHow to use WindowProc function Pin
nripun19-Mar-06 21:24
nripun19-Mar-06 21:24 
AnswerRe: How to use WindowProc function Pin
Nibu babu thomas19-Mar-06 21:28
Nibu babu thomas19-Mar-06 21:28 
AnswerRe: How to use WindowProc function Pin
_AnsHUMAN_ 19-Mar-06 22:38
_AnsHUMAN_ 19-Mar-06 22:38 
GeneralRe: How to use WindowProc function Pin
Monty219-Mar-06 23:11
Monty219-Mar-06 23:11 
AnswerRe: How to use WindowProc function Pin
Hamid_RT20-Mar-06 0:50
Hamid_RT20-Mar-06 0:50 
QuestionRuntime type checking help. Pin
Rostfrei19-Mar-06 21:00
Rostfrei19-Mar-06 21:00 
AnswerRe: Runtime type checking help. Pin
Nibu babu thomas19-Mar-06 21:12
Nibu babu thomas19-Mar-06 21:12 
GeneralRe: Runtime type checking help. Pin
Rostfrei19-Mar-06 21:28
Rostfrei19-Mar-06 21:28 
AnswerRe: Runtime type checking help. Pin
Monty219-Mar-06 21:14
Monty219-Mar-06 21:14 
GeneralRe: Runtime type checking help. Pin
Rostfrei19-Mar-06 21:26
Rostfrei19-Mar-06 21:26 
QuestionFolder lock Pin
pratap12319-Mar-06 20:54
pratap12319-Mar-06 20:54 
AnswerRe: Folder lock Pin
Nibu babu thomas19-Mar-06 20:59
Nibu babu thomas19-Mar-06 20:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.