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

A Cleanup API for Windows

, 24 Aug 2006 CPOL
Provides a general cleanup API for Windows, ported into Win32 and COM dynamic-link libraries.
cleanup_api_code.zip
Cleanup_DLL_Win32
Release
Cleanup.dll
Cleanup_Win32.lib
Cleanup_Client_COM
Cleanup_COM.tlb
Release
Cleanup_Client_COM.exe
res
Cleanup_Client.ico
Cleanup_Client.manifest
Cleanup_Client_CS
App.ico
bin
Release
Cleanup_Client_CS.exe
Interop.Cleanup_COMLib.dll
Cleanup_Client_C3.csproj.user
Cleanup_Client_CS.csproj.user
Cleanup_Client_MFC
Cleanup_Win32.lib
Release
Cleanup.dll
Cleanup_Client_MFC.exe
res
Cleanup_Client.ico
Cleanup_Client.manifest
Cleanup_DLL_COM
Cleanup_COM.def
Cleanup_COM.rgs
Cleanup_COMps.def
CleanupAPI.rgs
Release
Cleanup.dll
Cleanup_COM.tlb
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Cleanup_COMLib;

namespace Cleanup_Client_CS
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class frmCleanup : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private  Cleanup_COMLib.CleanupAPIClass objCleanup;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Button button4;
		private System.Windows.Forms.Button button5;
		private System.Windows.Forms.Button button6;
		private System.Windows.Forms.Button button7;


		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmCleanup()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			objCleanup =  new Cleanup_COMLib.CleanupAPIClass( );
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.button4 = new System.Windows.Forms.Button();
			this.button5 = new System.Windows.Forms.Button();
			this.button6 = new System.Windows.Forms.Button();
			this.button7 = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(48, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(192, 23);
			this.label1.TabIndex = 5;
			this.label1.Text = "Cleanup (cleanup API in COM DLL):";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(24, 48);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(224, 23);
			this.button1.TabIndex = 6;
			this.button1.Text = "IE Cache";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(24, 80);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(224, 23);
			this.button2.TabIndex = 7;
			this.button2.Text = "IE Cookies";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(24, 112);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(224, 23);
			this.button3.TabIndex = 8;
			this.button3.Text = "IE History";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(24, 144);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(224, 23);
			this.button4.TabIndex = 9;
			this.button4.Text = "IE Address Bar History";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// button5
			// 
			this.button5.Location = new System.Drawing.Point(24, 176);
			this.button5.Name = "button5";
			this.button5.Size = new System.Drawing.Size(224, 23);
			this.button5.TabIndex = 10;
			this.button5.Text = "Desktop Run History";
			this.button5.Click += new System.EventHandler(this.button5_Click);
			// 
			// button6
			// 
			this.button6.Location = new System.Drawing.Point(24, 208);
			this.button6.Name = "button6";
			this.button6.Size = new System.Drawing.Size(224, 23);
			this.button6.TabIndex = 11;
			this.button6.Text = "Desktop Recent Docs History";
			this.button6.Click += new System.EventHandler(this.button6_Click);
			// 
			// button7
			// 
			this.button7.Location = new System.Drawing.Point(24, 240);
			this.button7.Name = "button7";
			this.button7.Size = new System.Drawing.Size(224, 23);
			this.button7.TabIndex = 12;
			this.button7.Text = "Desktop Recycle Bin";
			this.button7.Click += new System.EventHandler(this.button7_Click);
			// 
			// frmCleanup
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(272, 278);
			this.Controls.Add(this.button7);
			this.Controls.Add(this.button6);
			this.Controls.Add(this.button5);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.label1);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmCleanup";
			this.Text = "C# Test Client for COM Cleanup API";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmCleanup());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
		    objCleanup.Delete_IECache(1,0);
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
		    objCleanup.Delete_IECookies(1, 0);
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
		    string strMsg;	

			strMsg =  "IE History is usually locked by Windows Explorer and  "; 
			strMsg += "IE. To test this function, please kill 'explorer' and ";
			strMsg += "'iexplore' processes with Task Manager.\r\n\r\nNote: ";
			strMsg += "you can easily restore shell by typing 'explorer' in   ";
			strMsg += "File/New task ... of Task Manager.";

			MessageBox.Show(strMsg, "C# Test Client");
			
			objCleanup.Delete_IEHistory(1, 0);
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
		    objCleanup.Delete_IEAddressBarHistory();
		}

		private void button5_Click(object sender, System.EventArgs e)
		{
		    string strMsg;	

			objCleanup.Delete_DesktopRunHistory();
			
			strMsg =  "Run History has been cleaned up. You can see the "; 
			strMsg += "results after logoff/logon or after reboot.";

			MessageBox.Show(strMsg, "C# Test Client");
		}

		private void button6_Click(object sender, System.EventArgs e)
		{
		    objCleanup.Delete_DesktopRecentDocsHistory();
		}

		private void button7_Click(object sender, System.EventArgs e)
		{
		    objCleanup.Delete_DesktopRecycleBinContents();
		}
	}
}

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 Code Project Open License (CPOL)

Share

About the Author

Marcel Lambert

United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 24 Aug 2006
Article Copyright 2006 by Marcel Lambert
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid