Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Shell Extensions for .NET Assemblies

, 17 Nov 2005 Ms-PL
Shell extensions to distinguish between .NET assemblies and Win32 applications and libraries.
// AssemblyIconOverlay.cpp : Implementation of CAssemblyIconOverlay

#include "stdafx.h"
#include "AssemblyIconOverlay.h"

// CAssemblyIconOverlay

STDMETHODIMP CAssemblyIconOverlay::GetOverlayInfo(LPWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags)
	DWORD dwSize;
	LPTSTR pszFileName = NULL;

	if (!pIndex || !pdwFlags)
		return E_POINTER;

	// Get the module handle for this module while mapped into the address space of the calling process.
	pszFileName = new TCHAR[cchMax];
	if (pszFileName)
		dwSize = GetModuleFileName(_AtlBaseModule.GetModuleInstance(), pszFileName, cchMax);
		if (0 == dwSize)
			hr = HRESULT_FROM_WIN32(GetLastError());
			wcsncpy(pwszIconFile, CT2W(pszFileName), cchMax);
			*pIndex = 0;

		delete [] pszFileName;
		pszFileName = NULL;

	return hr;

STDMETHODIMP CAssemblyIconOverlay::GetPriority(int *pPriority)
	if (!pPriority)
		return E_POINTER;

	*pPriority = 0;
	return S_OK;

#pragma warning( push )
#pragma warning( disable:4100 ) // dwAttrib is never used.
STDMETHODIMP CAssemblyIconOverlay::IsMemberOf(LPCWSTR pwszPath, DWORD dwAttrib)
	LPTSTR szExtension;

	szExtension = PathFindExtension(CW2T(pwszPath));
	if (_tcsicmp(szExtension, TEXT(".dll")) != 0 &&
		_tcsicmp(szExtension, TEXT(".netmodule")) != 0)
		return S_FALSE;

#if _WIN32_WINNT >= 0x0500
	// Return if the file is on a slow path.
	BOOL bIsSlow = PathIsSlow(CW2T(pwszPath), 0);
	if (bIsSlow)
		return S_FALSE;

	hr = m_spAsmInfo->IsAssembly((BSTR)pwszPath, NULL);

	// IsMemberOf should only return S_OK, S_FALSE, or E_FAIL;
	if (SUCCEEDED(hr))
		return hr;

	return E_FAIL;
#pragma warning( pop )

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, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


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.
Follow on   Twitter

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