Click here to Skip to main content
15,891,902 members
Articles / Desktop Programming / MFC

Custom URL Protocol for Invoking Application

Rate me:
Please Sign up or sign in to vote.
5.00/5 (18 votes)
6 Mar 2012CPOL3 min read 124.6K   14.8K   50  
Registering a custom URL protocol for invoking an application
#include <iostream>
#include <string>

#define URL_PROTOCOL_STRING			L"URL:%s Protocol"
#define URL_PROTOCOL				L"URL Protocol"
#define URL_PROTOCOL_DEFAULTICON	L"DefaultIcon"
#define URL_PROTOCOL_COMMAND		L"Shell\\Open\\command"
#define URL_PROTOCOL_OPEN			L"Shell\\Open"
#define URL_PROTOCOL_SHELL			L"Shell"

class CustomURLProtocol
{
	private:
		std::wstring		m_wszProtocolName;
		std::wstring		m_wszCompanyName;
		std::wstring		m_wszAppPath;

		DWORD				m_dwErrorCode;
		std::wstring		m_wszErrorMsg;

		void				FormatErrorMsg();

	public:

		std::wstring getProtocolName() {return m_wszProtocolName;}
		std::wstring getCompanyName() {return m_wszCompanyName;}
		std::wstring getAppPath() {return m_wszAppPath;}
		std::wstring getErrorMsg(){return m_wszErrorMsg;};

		void setProtocolName(std::wstring pwProtocolName){m_wszProtocolName = pwProtocolName;}
		void setCompanyName(std::wstring pwCompanyName){m_wszCompanyName = pwCompanyName;}
		void setAppPath(std::wstring pwAppPath){m_wszAppPath = pwAppPath;}
		
		CustomURLProtocol();
		CustomURLProtocol(std::wstring pwProtocolName, std::wstring pwCompanyName, std::wstring pwAppPath);

		int CreateCustomProtocol();
		int DeleteCustomProtocol();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions