How to extract out the domain name of given URL?

There are few ways to do it. Microsoft Win32 Internet API provides InternetCrackUrl. Look at example below:

#include <windows.h>
#include <wininet.h>
#include <tchar.h>

#pragma comment( lib, "wininet" )

BOOL GetHostName(LPCTSTR pszURL, LPTSTR pszHost, int cbHostBuf)
{ }

int main(int argc, char* argv[], char *envp[])
{ }


Shell provides nice Shell Lightweight Utility APIs. UrlGetPart function performs URL parsing. The following sample needs in latest Microsoft Platform SDK - http://www.microsoft.com/msdownload/platformsdk/setuplauncher.asp

#include <windows.h>
#include <shlwapi.h>
#include <tchar.h>

#pragma comment( lib, "shlwapi" )

int main(int argc, char* argv[], char *envp[])
{ }

Revision:1, Last Modified: 05/17/01 16:30, by Vadim Melnik. Visit my Homepage.