Click here to Skip to main content
11,571,155 members (69,398 online)
Click here to Skip to main content
Articles » Languages » C# » How To » Downloads
Add your own
alternative version

Enumerate and Host Control Panel Applets using C#.

, 15 Feb 2004 73.9K 2K 53
Demonstrates how to enumerate and host Windows Control Panel Applets using C# and unmanaged C++.
appletviewer_demo.zip
AppletViewer.exe
AppletEngine.dll
AppletProxy.dll
appletviewer_src.zip
AppletEngine
AppletEngine.csproj.user
bin
Debug
AppletEngine.dll
obj
Debug
temp
TempPE
AppletProxy
Debug
Exports.def
AppletViewer
App.ico
AppletViewer.csproj.user
bin
Debug
AppletEngine.dll
AppletProxy.dll
Release
AppletEngine.dll
AppletProxy.dll
AppletViewer.exe
obj
Debug
temp
TempPE
Release
temp
TempPE
using System;
using System.IO;
using System.Collections;

namespace AppletEngine
{
	/// <summary>
	/// The AppletEngine class provides methods for finding and creating AppletLibraries to manage Windows Control Panel Applets
	/// </summary>
	public class AppletEngine
	{		
		/// <summary>
		/// Initializes a new instance of the AppletEngine class
		/// </summary>
		public AppletEngine()
		{
			
		}

		/// <summary>
		/// Searches the specified path for control panel applet libraries
		/// </summary>
		/// <param name="path">The path to search</param>
		/// <returns>An array of FileInfo objects describing the applet libraries</returns>
		public FileInfo[] FindAppletLibraries(string path)
		{
			DirectoryInfo di = new DirectoryInfo(path);
			if (di != null)
			{
				return di.GetFiles("*.cpl");
			}
			return new FileInfo[] {};
		}

		/// <summary>
		/// Creates an AppletLibrary for each valid Windows Control Panel Applet described in the FileInfo array
		/// </summary>
		/// <param name="files">The files to create AppletLibraries from</param>
		/// <param name="hWnd">The window handle for the window above which each applet will display it's dialog</param>
		/// <returns>An array of AppletLibrary objects containing one or more Applet objects</returns>
		public ArrayList CreateApplets(FileInfo[] files, IntPtr hWnd)
		{
			ArrayList array = new ArrayList();
			foreach(FileInfo file in files)
			{
				try
				{
					AppletLibrary applet = new AppletLibrary(file.FullName, hWnd);
					array.Add(applet);
				}
				catch(System.Exception systemException)
				{
					System.Diagnostics.Trace.WriteLine(systemException);
				}
			}
			return array;
		}
	}
}

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 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

Share

About the Author

Mark Belles
Software Developer (Senior)
United States United States
Senior Application Developer specializing in Windows desktop and network development.

Professional Experience
- B.S. of Computer Science (Graduated 2001 - PSU)
- Senior Application Developer (8+ yrs)
- Microsoft Certified Professional

Primary Interests
- C#, C++, HTML, Javascript
- XML, ASP.NET, Web Services, SOAP, UDDI
- Socket programming and anything network related
- Reflection, Serialization, and Plugin Frameworks
- Owner-drawn controls and GDI+ goodness

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150624.2 | Last Updated 16 Feb 2004
Article Copyright 2004 by Mark Belles
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid