Click here to Skip to main content
11,568,180 members (38,057 online)
Click here to Skip to main content
Add your own
alternative version

Shell Extensions for .NET Assemblies

, 17 Nov 2005 Ms-PL 138.2K 2.4K 80
Shell extensions to distinguish between .NET assemblies and Win32 applications and libraries.
// AssemblyColumns.h : Declaration of the CAssemblyColumns

#pragma once
#include "resource.h"       // main symbols
#include "AsmShell.h"
#include <atlstr.h>
#include "rgsmap.h"

EXTERN_C const CLSID CLSID_AssemblyColumns;

// CAssemblyColumns

class ATL_NO_VTABLE CAssemblyColumns : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CAssemblyColumns, &CLSID_AssemblyColumns>,
	public IColumnProvider
{
public:
	CAssemblyColumns()
	{
	}

DECLARE_REGISTRY_RESOURCEID_EX(IDR_ASSEMBLYCOLUMNS)

BEGIN_REGISTRY_MAP(CAssemblyColumns)
	REGISTRY_GUID("CLSID", CLSID_AssemblyColumns)
END_REGISTRY_MAP()

BEGIN_COM_MAP(CAssemblyColumns)
	COM_INTERFACE_ENTRY_IID(IID_IColumnProvider, IColumnProvider)
END_COM_MAP()

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		HINSTANCE hInstance;
		HRESULT hr;

		// Get the resource instance.
		hInstance = _AtlBaseModule.GetResourceInstance();
		if (NULL != hInstance)
		{
			// Load the x86 resource strings as BSTRs.
			m_bstrWin32Executable.LoadString(hInstance, FT_WIN32_EXE);
			m_bstrWin32Library.LoadString(hInstance, FT_WIN32_DLL);
			m_bstrNETExecutable.LoadString(hInstance, FT_NET_EXE);
			m_bstrNETLibrary.LoadString(hInstance, FT_NET_DLL);
			m_bstrNETModule.LoadString(hInstance, FT_NET_MOD);

			// Load the ia64 resource strings as BSTRs.
			m_bstrWin32ExecutableIA64.LoadString(hInstance, FT_WIN64_EXE_I64);
			m_bstrWin32LibraryIA64.LoadString(hInstance, FT_WIN64_DLL_I64);
			m_bstrNETExecutableIA64.LoadString(hInstance, FT_NET_EXE_I64);
			m_bstrNETLibraryIA64.LoadString(hInstance, FT_NET_DLL_I64);
			m_bstrNETModuleIA64.LoadString(hInstance, FT_NET_MOD_I64);

			// Load the x64 resource strings as BSTRs.
			m_bstrWin32ExecutableX64.LoadString(hInstance, FT_WIN64_EXE_X64);
			m_bstrWin32LibraryX64.LoadString(hInstance, FT_WIN64_DLL_X64);
			m_bstrNETExecutableX64.LoadString(hInstance, FT_NET_EXE_X64);
			m_bstrNETLibraryX64.LoadString(hInstance, FT_NET_DLL_X64);
			m_bstrNETModuleX64.LoadString(hInstance, FT_NET_MOD_X64);

			// Load the resource strings as LPTSTRs.
			m_strFormatTitle.LoadString(hInstance, COL_TITLE_FORMAT);
			m_strFormatDesc.LoadString(hInstance, COL_DESC_FORMAT);
			m_strKeyTokenTitle.LoadString(hInstance, COL_TITLE_KEYTOKEN);
			m_strKeyTokenDesc.LoadString(hInstance, COL_DESC_KEYTOKEN);

			hr = m_spAsmInfo.CoCreateInstance(CLSID_AssemblyInfo);
			return hr;
		}
		
		return E_HANDLE;
	}
	
	void FinalRelease() 
	{
	}

private:
	CComPtr<IAssemblyInfo> m_spAsmInfo;

	// Store strings in instance fields to facilitate
	// different langids for different callers.

	// Cached FileType strings for x86.
	CComBSTR m_bstrWin32Executable;
	CComBSTR m_bstrWin32Library;
	CComBSTR m_bstrNETExecutable;
	CComBSTR m_bstrNETLibrary;
	CComBSTR m_bstrNETModule;

	// Cached FileType strings for ia64.
	CComBSTR m_bstrWin32ExecutableIA64;
	CComBSTR m_bstrWin32LibraryIA64;
	CComBSTR m_bstrNETExecutableIA64;
	CComBSTR m_bstrNETLibraryIA64;
	CComBSTR m_bstrNETModuleIA64;

	// Cached FileType strings for x64.
	CComBSTR m_bstrWin32ExecutableX64;
	CComBSTR m_bstrWin32LibraryX64;
	CComBSTR m_bstrNETExecutableX64;
	CComBSTR m_bstrNETLibraryX64;
	CComBSTR m_bstrNETModuleX64;

	// Cached column titles and descriptions.
	CAtlString m_strFormatTitle;
	CAtlString m_strFormatDesc;
	CAtlString m_strKeyTokenTitle;
	CAtlString m_strKeyTokenDesc;

public:

	// IColumnProvider methods
#pragma warning( push )
#pragma warning( disable:4100 ) // pcsi is never used.
	STDMETHOD(Initialize)(LPCSHCOLUMNINIT pcsi) { return S_OK; }
#pragma warning( pop )
	STDMETHOD(GetColumnInfo)(DWORD dwIndex, SHCOLUMNINFO* psci);
	STDMETHOD(GetItemData)(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT* pvarData);

};

OBJECT_ENTRY_AUTO(CLSID_AssemblyColumns, CAssemblyColumns)

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 Microsoft Public License (Ms-PL)

Share

About the Author

Heath Stewart
Program Manager Microsoft
United States United States
Heath Stewart is a happily married software engineer originally from the Midwest and a graduate of Iowa State University. Heath start programming early in life and enjoys continuous research and development in new languages, frameworks, and platforms. Fluent in many different programming languages, he has developed many large-scale software solutions for companies in different areas, such as Internet filtering, intrusion detection systems, production management systems, and web applications for various purposes. He also enjoys photography.

Currently, Heath is a Program Manager in the Visual Studio Professional Deployment Experience (VSPro DEX) team at Microsoft. Previous to his employment, he was a Microsoft MVP for Visual C#.

He is also a CodeProject protector and is happy to help the development community.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150624.2 | Last Updated 17 Nov 2005
Article Copyright 2002 by Heath Stewart
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid