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

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
{

	[ComImport]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	[Guid("00000002-0000-0000-C000-000000000046")]
	public interface IMalloc 
	{
		// Allocates a block of memory.
		// Return value: a pointer to the allocated memory block.
		[PreserveSig]
		IntPtr Alloc(
			UInt32 cb);		// Size, in bytes, of the memory block to be allocated. 
			
		// Changes the size of a previously allocated memory block.
		// Return value:  Reallocated memory block 
		[PreserveSig]
		IntPtr	Realloc(
			IntPtr pv,		// Pointer to the memory block to be reallocated.
			UInt32 cb);		// Size of the memory block (in bytes) to be reallocated.

		// Frees a previously allocated block of memory.
		[PreserveSig]
		void Free(
			IntPtr pv);		// Pointer to the memory block to be freed.

		// This method returns the size (in bytes) of a memory block previously allocated with 
		// IMalloc::Alloc or IMalloc::Realloc.
		// Return value: The size of the allocated memory block in bytes 
		[PreserveSig]
		UInt32 GetSize(
			IntPtr pv);		// Pointer to the memory block for which the size is requested.

		// This method determines whether this allocator was used to allocate the specified block of memory.
		// Return value: 1 - allocated 0 - not allocated by this IMalloc instance. 
		[PreserveSig]
		Int16 DidAlloc(
			IntPtr pv);		// Pointer to the memory block

		// This method minimizes the heap as much as possible by releasing unused memory to the operating system, 
		// coalescing adjacent free blocks and committing free pages.
		[PreserveSig]
		void HeapMinimize();
	}
}
	

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

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

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