URL
-
domingo, 04 de marzo de 2012 17:23
hey,
I need to find out if an url is valid, using c++ (VC++ 2008 express). Though I looked at other forums, but they didn't offer the solution to me. I tried to use InternetConnect function, but in on or another way, that one always returns a handel if you put in a url which doesnt even exist...
And I do not like to use 3rd party libraries. Maybe sb knows a method by using the urlmon library/header???
THanks a lot
Todas las respuestas
-
domingo, 04 de marzo de 2012 18:09Can you please define valid. Do you mean a valid syntax or the URL must exist.
-
domingo, 04 de marzo de 2012 19:17well, both of them. because I am programming a window which checks certain data on the net, so I need an existing url, and it needs to check if some urls do exist in real.
-
domingo, 04 de marzo de 2012 21:08
Try using the InternetOpenUrl(), as in:
HINTERNET hSession = InternetOpen (L"Is URL Valid", 0, NULL, NULL, 0); HINTERNET hOpenUrl = InternetOpenUrl (hSession, L"http://social.msdn.microsoft.com/Forums/en/vcgeneral/threads", NULL, 0, 1, 1); if (hOpenUrl == NULL) { // this is an invalid URL } InternetCloseHandle(hOpenUrl); InternetCloseHandle(hSession);I haven't executed the snippet myself, but check and let me know if it works!
- Propuesto como respuesta Helen ZhaoModerator lunes, 12 de marzo de 2012 1:21
- Marcado como respuesta Helen ZhaoModerator miércoles, 14 de marzo de 2012 2:03
-
lunes, 05 de marzo de 2012 16:24
well I got some strange results:
It said http://www.google.com doesnt exists. Also, I had to se the flag to working asynchronously, else my app would crash.
I didnt work...maybe you have a solution?
-
miércoles, 07 de marzo de 2012 5:50
Well, you must have typed something other that what I showed you. I tested my code and it worked perfectly fine first try.
Please post your code. It must be different from mine.
-
sábado, 10 de marzo de 2012 9:01
OK, I did change some variables name, I didnt gave it a handle (so instead of HINTERNET I just direclty compared it in the if clause)
If you say it works, I'll literally copy that.
-
sábado, 10 de marzo de 2012 9:06
I see the error I made.
Just a question:
why did you put in 1 as a paramater in OpenUrl???Why?
-
sábado, 10 de marzo de 2012 9:11
HINTERNET Url=InternetOpenUrl(Inet,"https://d/asdk",NULL,0,1,1);
if (Url==NULL)
game.update=true;
else
game.update=false;
InternetCloseHandle(Url);This is my code. It seems that with every string it says it exists////

