|
Hello all,
i am trying to extract the html code of a url. I have written this code
CString str;
GetDlgItemText(IDC_EDIT1,str);
DWORD dwLen = _MAX_PATH;
CString sCompareURL;
InternetCanonicalizeUrl(str,sCompareURL.GetBufferSetLength(_MAX_PATH),&dwLen,ICU_BROWSER_MODE);
HINTERNET Ihandle = InternetOpen("Browser", INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, INTERNET_FLAG_ASYNC);
HINTERNET hFile = InternetOpenUrl(Ihandle,str,NULL,0,0,0);
while(true)
{
const int MAX_BUFFER_SIZE = 65536;
unsigned long nSize = 0;
char szBuffer[MAX_BUFFER_SIZE+1];
BOOL bRet = InternetReadFile(hFile, szBuffer, MAX_BUFFER_SIZE, &nSize);
if(!bRet || nSize <= 0)
break;
szBuffer[nSize] = '\0';
}
but i m getting null in my hFile handle.
is there something wrong in my code. how could i modify my code.
can anybody help me in this
thanks in advance....
|
|
|
|
|
Hi,
May be due to "InternetOpen" must be the first function, but here its not.
What the GetLastError and InternetGetLastResponseInfo says after InternetOpenUrl.
|
|
|
|
|
GetLastError() returns 2 for some site but for some site it works fi9...
how to resolve this problem.....
|
|
|
|
|
GetLastError() 2;ERROR_FILE_NOT_FOUND is the error value,
This works for some site means you get the Handle right?
Then It should be "File not found", html file doesnot exist.
|
|
|
|
|
Hi neha,
The problem may be due to INTERNET_FLAG_ASYNC of InternetOpen(). Remove the flag and try. The code snippet will be as follows,
HINTERNET Ihandle = InternetOpen( "Browser",<br />
INTERNET_OPEN_TYPE_PRECONFIG,<br />
NULL, <br />
NULL, <br />
NULL);
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
no it doen't make a difference....
|
|
|
|
|
I tried your code snippet in my machine, and it works when i changed so. Thats why suggested that. Please recheck.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Why are you ignoring the return value from both InternetOpen() and InternetOpenUrl() ? If either of those fail, stop and figure out why. Use GetLastError() for this.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I Used Nonoverlapped I/O Serial Communications Because Of Converting to WIN CE
<br />
OpenPort()<br />
{<br />
m_hCOM = ::CreateFile( m_szCOMPort, GENERIC_READ | GENERIC_WRITE, <br />
0, NULL, OPEN_ALWAYS, NULL, <br />
NULL);<br />
<br />
...<br />
...<br />
...<br />
<br />
m_hThread = ::CreateThread(NULL, 0, ThreadRcv, this, 0, &dwThreadID);<br />
}<br />
When A COM PORT is opened I created A Thread For Receving Response Data
<br />
DWORD WINAPI CSerialComm::ThreadRcv(void* arg)<br />
{<br />
CSerialComm *pCom = (CSerialComm*)(arg);<br />
<br />
if ( !SetCommMask(pCom->m_hCOM, EV_RXCHAR) )<br />
return 0;<br />
while( pCom->m_bConnected == TRUE )<br />
{<br />
if ( WaitCommEvent(pCom->m_hCOM, &dwRcvEvent, NULL) )<br />
{<br />
.......<br />
}<br />
}<br />
....<br />
<br />
return 0;<br />
}<br />
But While ThreadRcv is running( Blocked WaitCommEvent Func ), Any attempt to send Data To COM
PORT doesn't work. ( Blocked In WriteFile(...) )
HELP ME~ plz
|
|
|
|
|
sungtany wrote: But While ThreadRcv is running( Blocked WaitCommEvent Func ), Any attempt to send Data To COM PORT doesn't work. ( Blocked In WriteFile(...) )
Of course, since you're not using overlapped I/O.
If you don't use overlapped I/O the driver only handles one IRP at a time, which means e.g. that a write operation will block while waiting for a read operation to timeout.
In this case it is essential that you set the COMMTIMEOUTS to make a read operation timeout within a time frame that suits your needs.
I would try the following:
Spawn a worker thread that read data from queue containing data to be sent.
The worker thread would examine the queue if it contains data it would be sent.
Issue a read operation that will eventually time out, the read data should be put in a queue containing received data and the main thread should be notified with a user defined message that some data has been received. Then the main thread can extract the read data from the queue and do whatever needs to be done with the data.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thanks I'll try your comments
|
|
|
|
|
How do I convert _tcscpy to _tcscpy_s in Visual Studio 2005. i need to do this to remove the warnings.
|
|
|
|
|
You could use "Find Replace" utility.
Q. Or do you want to suppress the warning ?
A. For suppressing the warning you could use
#pragma warning(disable: WarningNumber)
Regards,
Paresh.
|
|
|
|
|
The pending is stands for Secure. Its a protection build in to prevent buffer overruns.
You just need to give the size of the destination buffer.
See help. Clickety[^]
codito ergo sum
|
|
|
|
|
tom groezer wrote: How do I convert _tcscpy to _tcscpy_s
You don't need to convert. You need to use secured version advised by the compiler.
Refer Security Enhancement in CRT[^] for more information.
Prasad
MS MVP - VC++
|
|
|
|
|
tell me how shld i start to mak a project which displays video from camera(not webcam)using DirectX sdk....
NT
|
|
|
|
|
Did you see DirectX section on the codeproject?
|
|
|
|
|
I am working on a project where i have to generate a lot of image files. While i am doing this, the size of the page file increases such that i run out of memory. I am thinking of flushing page file at certain intervals but not sure if its the right idea. I am not even sure if it is possible to do it programatically. Is there anyway to programatically flush the page file??
Regards,
Srinivas
|
|
|
|
|
I dont think its good idea i dont even think it would be posible. page file will be automaticly flushed when you will delete your in memory images. if you still have images in memory loaded and flush page file you will be in trouble bro because when you will access image it would try to load from pagefile and there you wont find anything.
|
|
|
|
|
Hello to every one..
my question is i have a menu bar in that two menus im keeping..
1. test
2.execute
In the above test menu i have some menu items..
while im executing ,my test menu items alone should be enabled.Rest sholud be in disabled state..
if i click first menu item , from the test it should automatically enable the next menu items of execute ..
plz help me..
vikram..
|
|
|
|
|
|
Whats the result if you run this code?
CMenu* m_MainMenu= GetMenu();
CMenu* m_Submenu = m_MainMenu->GetSubMenu(0);
m_Submenu->EnableMenuItem(ID_TEST, MF_BYCOMMAND | MF_DISABLED );
|
|
|
|
|
In my code, I have instantiated a template class in the following manner:
CallbackWrapperSpecific<MainWindow, void (MainWindow::*)(int&), int>* cbwsPtr = new CallbackWrapperSpecific<MainWindow, void (MainWindow::*)(int&), int>(this, &MainWindow::DoWork, i);
The above object is a functor, which encapsulates a class member function pointer. In this case, I assume that the class member function pointer always has a pointer to this (meaning that the class does not go out of scope while the functor exists), but I would not like to make the assumption that the functor pointer will not go out of scope, because it may very well do so until the time that the function pointer actually gets called. If it goes out of scope before that, then I will lose the pointer to that object and run into a memory leak. The difficulty here is not in capturing that pointer and deleting it later, but rather, in capturing that pointer, and making sure to delete it as a class of the type that I have listed above. Manually recasting to such a long-winded (and infinitely varying) type is not a good solution.
Because new and delete check the sizes of the objects (I think), would it be a good idea in this case to call malloc(), store both the pointer and the size of the pointer initially, and then call free() on the pointer, while specifying a size?
|
|
|
|
|
Dear all
build any one cube with VC++.who have such snippet? please send me, thanks a lot.
Regards
Li Zhiyuan
6/15/2007
|
|
|
|
|
you definately do need help.
Please read the guidelines for posting questions (at the top of the forum), then maybe modify your post to reflect those guidelines.
Then maybe you might get a better response
|
|
|
|