Click here to Skip to main content
Click here to Skip to main content

Project Line Counter Add-In v2.10 for VS.NET and VC6

By , 29 Jun 2003
 
linecount_dll.zip
LineCount.chm
LineCount.dll
WWhizInterface.mod
linecount_src.zip
ExtrnSrc
Help
arrowrt.gif
Index.hhk
LineCount.chm
LineCount.hhp
mailto.gif
metl011.gif
PLC.gif
small_exclamation.gif
TOC.hhc
weblink.gif
LineCount.clw
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
LineCount_VC5.dsp
LineCount_VC5.dsw
Release
LineCount.chm
LineCount.dll
WWhizInterface.mod
res
idr_main.ico
project.ico
TBarLrge.bmp
TBarMedm.bmp
title.ico
plc110src.zip [file error]
plc111.zip
LineCount.chm
LineCount.dll
WWhizInterfaceInstaller210Beta1.exe
plc111src.zip
LineCount.chm
LineCount.dll
Source
Debug
WWhizInterface2D.mod
ExtrnSrc
Help
.cvsignore
arrowrt.gif
Index.hhk
LineCount.hhp
mailto.gif
metl011.gif
PLC.gif
small_exclamation.gif
TOC.hhc
weblink.gif
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
LineCount_VC5.dsp
LineCount_VC5.dsw
res
idr_main.ico
project.ico
TBarLrge.bmp
TBarMedm.bmp
title.ico
WWhizInterfaceInstaller210Beta1.exe
plc150.zip
LineCount.chm
LineCount.dll
Reports
SampleAnalysis.xls
Simple-BW.xsl
Simple-Color.xsl
WWhizInterfaceInstaller212.exe
plc150src.zip
LineCount.chm
LineCount.dll
SampleAnalysis.xls
Simple-BW.xsl
Simple-Color.xsl
WWhizInterface2D.mod
.cvsignore
arrowrt.gif
Index.hhk
info_dot_small.gif
linecount.hhp
mailto.gif
PLC.gif
small_exclamation.gif
TOC.hhc
weblink.gif
LineCount.clw
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
HdrDownA.bmp
HdrUpA.bmp
idr_main.ico
info.ico
project.ico
TBarLrge.bmp
TBarMedm.bmp
title.ico
WWhizInterfaceInstaller212.exe
plc200.zip
LineCount.cab
WWhizInterface30VC6_1016.exe
plc200src.zip
.cvsignore
WWhizInterface2D.mod
ResizableLib
.cvsignore
ResizableLib.dsp
ResizableLib.dsw
.cvsignore
arrowrt.gif
Index.hhk
info_dot_small.gif
LineCount.hhp
mailto.gif
PLC.gif
small_exclamation.gif
TOC.hhc
weblink.gif
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
ObjModelVC6
ObjModelVC7
dte.tlh
MSADDNDR.tlh
MSO.tlh
HdrDownA.bmp
HdrUpA.bmp
idr_main.ico
info.ico
lcgo.bmp
LineCountVC6.rgs
LineCountVC7.rgs
project.ico
TBarLrge.bmp
TBarMedm.bmp
title.ico
plc210.zip
SetupPLC210.exe
plc210src.zip
.cvsignore
WWhizInterface2D.mod
.cvsignore
ResizableLib.dsp
ResizableLib.dsw
.cvsignore
arrowrt.gif
Index.hhk
info_dot_small.gif
LineCount.hhp
mailto.gif
PLC.gif
small_exclamation.gif
TOC.hhc
weblink.gif
LineCount.def
LineCount.dsp
LineCount.dsw
LineCount.odl
dte.tlh
MSADDNDR.tlh
MSO.tlh
gallery.xsl
HdrDownA.bmp
HdrUpA.bmp
idr_main.ico
info.ico
lcgo.bmp
LineCountVC6.rgs
LineCountVC7.rgs
project.ico
TBarLrge.bmp
TBarMedm.bmp
title.ico
/***************************************************************************/
/* NOTE:                                                                   */
/* This document is copyright (c) by Oz Solomonovich, and is bound by the  */
/* MIT open source license (www.opensource.org/licenses/mit-license.html). */
/* See License.txt for more information.                                   */
/***************************************************************************/

// LineCount.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include <initguid.h>
#include "LineCount.h"
#include "Config.h"
#include "ExtrnSrc\AddInComm.h"
#include "ExtrnSrc\AICLoader.h"
#include "ParserManager.h"

#ifdef TARGET_VC6
#include "Commands.h"
#include "DSAddIn.h"
#endif

#ifdef TARGET_VC7
#include "ConnectVC7.h"
#endif

#define REG_KEY_BASE    "WndTabs.com\\LineCounter"
#define REG_KEY_SUB     "Options"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CComModule _Module;

int g_iVerMaj;
int g_iVerMin;


BEGIN_OBJECT_MAP(ObjectMap)
    #ifdef TARGET_VC6
        OBJECT_ENTRY(CLSID_DSAddIn, CDSAddIn)       // VC6 addin
    #endif
    #ifdef TARGET_VC7
        OBJECT_ENTRY(__uuidof(Connect), CConnect)   // VC7 addin
    #endif
END_OBJECT_MAP()

#ifdef TARGET_VC6
BEGIN_OBJECT_MAP(ObjectMapVC6Only)
    OBJECT_ENTRY(CLSID_DSAddIn, CDSAddIn)
END_OBJECT_MAP()
#endif

/////////////////////////////////////////////////////////////////////////////
// CLineCountApp

class CLineCountApp : public CWinApp
{
public:
    CLineCountApp();

// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CLineCountApp)
    public:
    virtual BOOL InitInstance();
    virtual int ExitInstance();
    //}}AFX_VIRTUAL

    //{{AFX_MSG(CLineCountApp)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CLineCountApp

BEGIN_MESSAGE_MAP(CLineCountApp, CWinApp)
    //{{AFX_MSG_MAP(CLineCountApp)
        // NOTE - the ClassWizard will add and remove mapping macros here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// The one and only CLineCountApp object

CLineCountApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CLineCountApp construction

CLineCountApp::CLineCountApp()
{
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// CLineCountApp initialization
    
CString GetVersionForRegKey()
{
    char s[256];

    char path[MAX_PATH];
    GetModuleFileName(AfxGetInstanceHandle(), path, sizeof(path));
    aiclGetFileVersion(path, s);

    char *pos = strchr(s, '.');
    if (pos == NULL) return "0.0";
    ++pos;
    if (!*pos) return "0.0";
    if (isdigit(*pos)) { ++pos; }
    *pos = '\0';

    if (RUNNING_IN_DOT_NET())
    {
        strcat(s, ".NET");
    }

    return s;
}

CString GetRegKeyBase()
{
    return ("Software\\" REG_KEY_BASE "\\") + GetVersionForRegKey();
}


BOOL CLineCountApp::InitInstance()
{
    SetRegistryKey(REG_KEY_BASE);
    CString sVerForReg = GetVersionForRegKey();
    ASSERT(strlen(m_pszProfileName) > (size_t)sVerForReg.GetLength());
    strcpy((char *)m_pszProfileName, sVerForReg);

    RegisterHHWindowType(1, "MainWnd");

    // Trick: VC6 tries to find all the registered objects from this module
    // (when adding through Tools|Customize|Addins), so we'll only register
    // the VC6 addin if we detect that we are running under VC6
#ifdef TARGET_VC6
    if (GetModuleHandle("MSDEV.EXE") != NULL  ||
        GetModuleHandle("EVC.EXE")   != NULL)
    {
        _Module.Init(ObjectMapVC6Only, m_hInstance);
    }
    else
#endif
    {
        _Module.Init(ObjectMap, m_hInstance);
    }

    return CWinApp::InitInstance();
}

int CLineCountApp::ExitInstance()
{
    _Module.Term();
    return CWinApp::ExitInstance();
}

HADDIN s_hAddin = NULL;

void OnAddinConnect()
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    aiclUseDebugLibrary(FALSE);
    aiclLoadAICLibrary(AfxGetInstanceHandle());

    GetConfiguration();

    CParserManager::Get().LoadConfig();

    // == Register With AddInComm ==
    // LineCounter doens't export any commands, but registration broadcasts
    // it's presence.
    char buf[256], *p;
    int verextra;

    strcpy(buf, "Build ");
    p = buf + strlen(buf);

    // use loader facilities to read own version resource...
    aiclGetModuleVersion("LineCount.dll", p);  

    // extract it numerically
    sscanf(p, "%d.%d.%d", &g_iVerMaj, &g_iVerMin, &verextra);

    // do actual registration
    s_hAddin = AICRegisterAddIn("Line Counter", g_iVerMaj, g_iVerMin, 
        verextra);
    AICSetAddInVersionString(s_hAddin, buf);
}

void OnAddinDisconnect()
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    if (s_hAddin)
    {
        AICUnregisterAddIn(s_hAddin);
    }

    CParserManager::Get().SaveConfig();
    WriteConfiguration();
}

/////////////////////////////////////////////////////////////////////////////
// Special entry points required for inproc servers

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    HRESULT hr = S_FALSE;
    hr = _Module.GetClassObject(rclsid, riid, ppv);
    return hr;
}

STDAPI DllCanUnloadNow(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    HRESULT hr = AfxDllCanUnloadNow();
    if (hr == S_OK)
    {
        hr = (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
    }
    return hr;
}

// by exporting DllRegisterServer, you can use regsvr32.exe
STDAPI DllRegisterServer(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    return _Module.RegisterServer(TRUE);
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    return _Module.UnregisterServer();
}


/////////////////////////////////////////////////////////////////////////////
// Debugging support

// GetLastErrorDescription is used in the implementation of the VERIFY_OK
//  macro, defined in stdafx.h.

#ifdef _DEBUG

void GetLastErrorDescription(CComBSTR& bstr)
{
    CComPtr<IErrorInfo> pErrorInfo;
    if (GetErrorInfo(0, &pErrorInfo) == S_OK)
        pErrorInfo->GetDescription(&bstr);
}

#endif //_DEBUG

By viewing downloads associated with this article you agree to the Terms of use 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 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

Oz Solomon
Experion
Canada Canada
Member
You may know Oz from his WndTabs days. Oz has long since left client side development to work on web technologies and to consult in the R&D management field.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 30 Jun 2003
Article Copyright 2000 by Oz Solomon
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid