示例#1
0
BOOL SetProtocol(const char *szProtocol, const char *szCommand, const char *szModule)
	{
	
	if (!SetRegClassesRoot(szProtocol,NULL,"URL: Protocol")) return FALSE;
	if (!SetRegClassesRoot(szProtocol,"URL Protocol","")) return FALSE;

	char szCmd[_MAX_PATH+1],szKey[_MAX_PATH+1];
	sprintf(szCmd,szCommand,szModule);
	sprintf(szKey,"%s\\shell\\open\\command",szProtocol);
	if (!SetRegClassesRoot(szKey,"",szCmd)) return FALSE;

	char szIconpath[_MAX_PATH+1];
	sprintf(szIconpath,"%s,1",szModule);
	sprintf(szKey,"%s\\DefaultIcon",szProtocol);
	if (!SetRegClassesRoot(szKey,"",szIconpath)) return FALSE;

	return TRUE;
	}
示例#2
0
bool SetRegShell(const wchar_t *szClassName,
                 const wchar_t *szShellName,
                 const wchar_t *szShellCaption,
                 const wchar_t *szCommand,
                 bool fMakeDefault)
{
	wchar_t szKeyName[256+1];
	// Set shell caption
	_snwprintf(szKeyName,256,L"%s\\Shell\\%s",szClassName,szShellName);
	if (!SetRegClassesRoot(szKeyName, NULL, szShellCaption)) return false;
	// Set shell command
	_snwprintf(szKeyName,256,L"%s\\Shell\\%s\\Command",szClassName,szShellName);
	if (!SetRegClassesRoot(szKeyName, NULL, szCommand)) return false;
	// Set as default command
	if (fMakeDefault)
	{
		_snwprintf(szKeyName, 256,L"%s\\Shell", szClassName);
		if (!SetRegClassesRoot(szKeyName, NULL, szShellName)) return false;
	}
	return true;
}