Click here to Skip to main content
13,094,732 members (95,883 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

// Commands.cpp : Implementation of CCommands
#include "stdafx.h"
#include "OpenVC.h"
#include "Commands.h"

#include "DlgClasses.h"

// CCommands


// ICommands

	// save-all

	// obtain the MSDEV CWinApp object:
	// (this is the "magic")
	CWinApp* pApp = AfxGetApp();
	if (NULL == pApp) return E_FAIL;

	// enumerate document templates, looking for workspace doc template:
	POSITION posdt = pApp->GetFirstDocTemplatePosition();
	while (NULL != posdt)
		CDocTemplate* pdt = pApp->GetNextDocTemplate(posdt);
		if (0 == strcmp("CProjectWorkspaceDocTemplate", pdt->GetRuntimeClass()->m_lpszClassName))
			// found it, grab the first (and only) document:
			POSITION posdoc = pdt->GetFirstDocPosition();
			if (NULL == posdoc) break;

			CDocument* pdoc = pdt->GetNextDoc(posdoc);
			if (NULL == pdoc) break;

			// stash the workspace path+file:
			CString strWorkspace = pdoc->GetPathName();
			if (0 == strWorkspace.GetLength()) break;

			// close the workspace
			pApp->GetMainWnd()->SendMessage(WM_COMMAND, 36633); // magic number for "File/Close Workspace"

			// build the ncb filename
			CString strNCB = strWorkspace.Left(strWorkspace.GetLength()-4);
			strNCB += ".ncb";

			// delete the ncb
			if (FALSE == ::DeleteFile(strNCB))
				AfxMessageBox(CString("Error deleting NCB file:\n\n") + strNCB);
			// reopen the workspace

	return S_OK;

STDMETHODIMP CCommands::ShowInnards()
	// show our dialog
	CDlgClasses* pDlg = new CDlgClasses;

	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.170813.1 | Last Updated 18 Sep 2000
Article Copyright 2000 by Nick Hodapp
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid