There is another option to check if a url is valid. But the problem is that wroks only for windows systems, but I'll show it here anyway.
Here is the code:
#include <windows.h>
HMODULE hUrlMon = LoadLibrary( L"urlmon.dll" );
wchar_t url[] = TEXT("http://www.google.com"); //the url example to test if is valid or not.
if( hUrlMon )
{
typedef HRESULT (__stdcall *isValidURL_ptr)( LPBC pBC, LPCWSTR szURL, DWORD dwReserved );
isValidURL_ptr isValidURL_fn = ( isValidURL_ptr )GetProcAddress( hUrlMon, "IsValidURL" );
HRESULT hr = isValidURL_fn( NULL, url, 0 );
if( S_OK == hr )
{
qDebug() << "URL Valid: " << hr;
}else{
qDebug() << "URL Invalid: " << hr;
}
}
#include <windows.h>
HMODULE hUrlMon = LoadLibrary( L"urlmon.dll" );
wchar_t url[] = TEXT("http://www.google.com"); //the url example to test if is valid or not.
if( hUrlMon )
{
typedef HRESULT (__stdcall *isValidURL_ptr)( LPBC pBC, LPCWSTR szURL, DWORD dwReserved );
isValidURL_ptr isValidURL_fn = ( isValidURL_ptr )GetProcAddress( hUrlMon, "IsValidURL" );
HRESULT hr = isValidURL_fn( NULL, url, 0 );
if( S_OK == hr )
{
qDebug() << "URL Valid: " << hr;
}else{
qDebug() << "URL Invalid: " << hr;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks