Click here to Skip to main content
15,885,309 members
Articles / Programming Languages / C#

SCSI Library in C# - Burn CDs and DVDs, Access Hard Disks, etc.

Rate me:
Please Sign up or sign in to vote.
4.77/5 (48 votes)
19 Jun 2017Ms-PL6 min read 145.3K   8.1K   146  
Ever wonder how programs like Nero work? They make their own SCSI libraries... like this!
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace System.Shell
{
	[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214e4-0000-0000-c000-000000000046")]
	public interface IContextMenu
	{
		/// <summary>You MUST check the return value!</summary>
		/// <returns>If successful, returns an HRESULT value that has its severity value set to SEVERITY_SUCCESS and its code value set to the offset of the largest command identifier that was assigned, plus one. For example, if idCmdFirst is set to 5 and you add three items to the menu with command identifiers of 5, 7, and 8, the return value should be MAKE_HRESULT(SEVERITY_SUCCESS, 0, 8 - 5 + 1). Otherwise, it returns a COM error value.</returns>
		[PreserveSig]
		int QueryContextMenu([In] IntPtr hmenu, [In] int indexMenu, [In] int idCmdFirst, [In] int idCmdLast, [In] ContextMenuFlags uFlags);
		void InvokeCommand([In, MarshalAs(UnmanagedType.LPStruct)] CMINVOKECOMMANDINFO pici);
		/// <summary>You MUST check the return value!</summary>
		[PreserveSig]
		int GetCommandString([In] IntPtr idCmd, [In] CommandStringInformation uType, IntPtr pReserved, [Out, MarshalAs(UnmanagedType.AsAny, SizeParamIndex = 4)] object pszName, [In] int cchMax);
	}

	[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214f4-0000-0000-c000-000000000046")]
	public interface IContextMenu2 : IContextMenu
	{
		void HandleMenuMsg([In] int uMsg, [In] IntPtr wParam, [In] IntPtr lParam);
	}

	[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("BCFCE0A0-EC17-11d0-8D10-00A0C90F2719")]
	public interface IContextMenu3 : IContextMenu2
	{
		unsafe void HandleMenuMsg2([In] int uMsg, [In] IntPtr wParam, [In] IntPtr lParam, [Out, Optional] IntPtr* plResult);
	}
}

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)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions