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

Implement an Autoplay Handler

, 18 Sep 2006 CPOL
Implementing an Autoplay handler in C#.
autoplaydemo_demo.zip
Almdal.RegistryScript.dll
Almdal.SharedPipes.dll
AutoPlayDemo.exe
AutoPlayListener.dll
autoplaydemo_src.zip
AutoPlayDemo
Autoplay.ico
AutoPlayDemo.csproj.user
bin
Properties
Settings.settings
Resources
AutoPlayListener
Autoplay.ico
AutoPlayListener.snk
bin
Properties
Resources
Autoplay.ico
RegistryScript
Almdal.RegistryScript.snk
bin
Properties
SharedPipies
Almdal.SharedPipes.snk
bin
Properties
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Diagnostics;

/*****************************************************************************************
 *  Copyright (c) 2006 T. ALmdal
 *
 *  Permission is hereby granted, free of charge, to any person obtaining 
 *  a copy of this software and associated documentation files (the "Software"),
 *  to deal in the Software without restriction, including without limitation 
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 *  and/or sell copies of the Software, and to permit persons to whom the 
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included 
 *  in all copies or substantial portions of the Software.
 *  
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 * 
/*******************************************************************************************/
namespace Almdal.AutoPlayListener {
	/// <summary>
	/// This structure is used with the CFSTR_SHELLIDLIST clipboard format to transfer the pointer 
	/// to an item identifier list (PIDL) of one or more Shell namespace objects.
	/// </summary>
    public class CIDA {
        private IntPtr _cida;
        private IntPtr _aoffset;
        /*
         * Format of the CIDA structure is
         *  UINT cidl       -   number of relative IDLists
         *  UINT aoofset[1] -   [0] folder IDList, [1]-[cidl]: item IDList
         */

        public CIDA(IntPtr cida) {
            _cida = cida;
            _aoffset = new IntPtr((int)cida + IntPtr.Size);
        }

        public int Count {
            get { return (int)Marshal.ReadIntPtr(_cida); }
        }

        public PIdl Folder {
            get { return this[0]; }
        }

        public PIdl this[int i] {
            get {
                //  add the PIDLs aoffset value to the address of the structure
                IntPtr pidl = new IntPtr(((int)_cida) + (int)Marshal.ReadIntPtr(_aoffset, sizeof(uint) * i));
                return new PIdl(pidl);
            }
        }

        public IntPtr Detach() {
            IntPtr cida = _cida;
            _cida = IntPtr.Zero;
            return cida;
        }

        public static explicit operator IntPtr(CIDA p) { return p._cida; }
        public static explicit operator CIDA(IntPtr p) { return new CIDA(p); }
    }
}

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

Tim Almdal

Canada Canada
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 18 Sep 2006
Article Copyright 2006 by Tim Almdal
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid