Click here to Skip to main content
12,888,931 members (51,798 online)
Click here to Skip to main content


165 bookmarked
Posted 13 Mar 2003

C# does Shell, Part 4

, 26 Mar 2003 Ms-PL
This article is about the AutoComplete features enabled by windows and how to use them with C#. AutoComplete is the ability to expand strings written in an edit box. The article will develop a class for using this functionality in you applications.
using System;
using System.Runtime.InteropServices;

namespace ShellLib

	public class ShellFunctions
		public static IMalloc GetMalloc()
			IntPtr ptrRet;
			ShellApi.SHGetMalloc(out ptrRet);
			Object obj = Marshal.GetTypedObjectForIUnknown(ptrRet,GetMallocType());
			IMalloc imalloc = (IMalloc)obj;
			return imalloc;

		public static IShellFolder GetDesktopFolder()
			IntPtr ptrRet;
			ShellApi.SHGetDesktopFolder(out ptrRet);

			System.Type shellFolderType = System.Type.GetType("ShellLib.IShellFolder");
			Object obj = Marshal.GetTypedObjectForIUnknown(ptrRet,shellFolderType);
			IShellFolder ishellFolder = (IShellFolder)obj;

			return ishellFolder;

		public static Type GetShellFolderType()
			System.Type shellFolderType = System.Type.GetType("ShellLib.IShellFolder");
			return shellFolderType;

		public static Type GetMallocType()
			System.Type mallocType = System.Type.GetType("ShellLib.IMalloc");
			return mallocType;

		public static Type GetFolderFilterType()
			System.Type folderFilterType = System.Type.GetType("ShellLib.IFolderFilter");
			return folderFilterType;

		public static Type GetFolderFilterSiteType()
			System.Type folderFilterSiteType = System.Type.GetType("ShellLib.IFolderFilterSite");
			return folderFilterSiteType;

		public static IShellFolder GetShellFolder(IntPtr ptrShellFolder)
			System.Type shellFolderType = GetShellFolderType();
			Object obj = Marshal.GetTypedObjectForIUnknown(ptrShellFolder,shellFolderType);
			IShellFolder RetVal = (IShellFolder)obj;
			return RetVal;


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

Arik Poznanski
Software Developer (Senior) Verint
Israel Israel
Arik Poznanski is a senior software developer at Verint. He completed two B.Sc. degrees in Mathematics & Computer Science, summa cum laude, from the Technion in Israel.

Arik has extensive knowledge and experience in many Microsoft technologies, including .NET with C#, WPF, Silverlight, WinForms, Interop, COM/ATL programming, C++ Win32 programming and reverse engineering (assembly, IL).

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 27 Mar 2003
Article Copyright 2003 by Arik Poznanski
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid