Click here to Skip to main content
12,828,699 members (54,639 online)
Click here to Skip to main content


278 bookmarked
Posted 10 Sep 2000

Undocumented Visual C++

, 17 Sep 2000
Spelunking in the Badlands of MSDEV
// ---------------
// You may use, compile or redistribute this source as part of your application 
// for free. You may not redistribute it as a part of a software development 
// library without the agreement of the author. If the sources are 
// distributed along with the application, you should leave the original 
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
// Nick Hodapp

// DSAddin.cpp : Implementation of COpenVC
#include "stdafx.h"
#include "OpenVC.h"
#include "OpenVCAddin.h"

// COpenVC

// IDSAddin

STDMETHODIMP COpenVC::OnConnection(IApplication* piApplication, VARIANT_BOOL bFirstTime, long dwCookie, VARIANT_BOOL* pbOnConnection)
	// prepare to fail!
	*pbOnConnection = VARIANT_FALSE;

	// create our command object
	m_pCommands->m_piApplication = piApplication;
	CComQIPtr<IDispatch> piDispCmds = m_pCommands;

	// tell VC about us:
	if (FAILED(piApplication->SetAddInInfo((long)_Module.GetModuleInstance(), piDispCmds, IDR_TOOLBAR_MEDIUM, IDR_TOOLBAR_LARGE, dwCookie)))
		return S_OK;

	// register our commands with VC
	_bstr_t		 bstrCmd,
					 bstrDeleteNCB = "DeleteNCB",
					 bstrShowInnards = "ShowInnards";

	// DeleteNCB
	bstrCmd = "DeleteNCB\nDeleteNCB\nDeletes corrupt NCB files.\nDeleteNCB";
	if (FAILED(piApplication->AddCommand(bstrCmd, bstrDeleteNCB, 0, dwCookie, &bRet) || VARIANT_FALSE == bRet))
		return S_OK;

	// ShowInnards
	bstrCmd = "ShowInnards\nShowInnards\nA Sample Addin Command\nShowInnards";
	if (FAILED(piApplication->AddCommand(bstrCmd, bstrShowInnards, 1, dwCookie, &bRet) || VARIANT_FALSE == bRet))
		return S_OK;

	// create toolbar:
	if (VARIANT_TRUE == bFirstTime)
		piApplication->AddCommandBarButton(dsGlyph, bstrDeleteNCB, dwCookie);
		piApplication->AddCommandBarButton(dsGlyph, bstrShowInnards, dwCookie);

	// success
	*pbOnConnection = VARIANT_TRUE;

	return S_OK;

	// cleanup!
	m_pCommands = NULL;

	return S_OK;

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Nick Hodapp
Web Developer
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 18 Sep 2000
Article Copyright 2000 by Nick Hodapp
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid