我实现了一个右键菜单功能,目的是当选择一般文件、文件夹时,增加一个菜单项,选择其它对象(如我的电脑时,不增加该菜单项)。现在是当选择了“我的电脑”时也出现,请问如何 判断 选择的是“我的电脑”,还是一般文件、文件夹?
谢谢。

解决方案 »

  1.   

    你的右键菜单是给谁添加的?是ListView吗?这个你在设计列表时,就应该给其它对象打上Type类型识别了啊,然后识别那个列的值来改变右键菜单的项。
      

  2.   

    .Net 4.0之前NSE不支持托管代码
    你怎么加的菜单?注册表?
      

  3.   

    能不能使用 DirectoryInfo 把名字获取了来判断
      

  4.   

    COM扩展话是在IShellExtInit.Initialize里面判断。注册表里面写死的不能改。
      

  5.   

    去网上搜一下Windows 7 API Code Pack for .NET,里面有很多Shell方面的代码
      

  6.   

    判断LPCITEMIDLLIST pidlFolder和LPDATAOBJECT lpdobj,
      

  7.   


    如果你用的是C#
    if( 某某控件的选择路径= Environment.GetFolderPath(  Environment.SpecialFolder.MyComputer))
    {....}
      

  8.   


    File.Exists(@"C:\temp")        // true 是文件  
    Directory.Exists(@"C:\temp")   // true 是目录
      

  9.   

    shell编程用的较多的话,推荐老外做的一个小助手http://www.corrupteddatarecovery.com/File-Data/ShellBasics.dll-----1.0.0.2.asp
      

  10.   

    另外,试试判断其path是否为"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}",这个是"我的电脑"的path信息
      

  11.   


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;namespace MDI
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
             private void Form1_Load(object sender, EventArgs e)
            {        }        private void button1_Click(object sender, EventArgs e)
            {
                //我的电脑 ,没有目录
                textBox1.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
                //我的文档,有具体地址显示
                textBox2.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                //桌面,有地址显示
                textBox3.Text = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            }
        }
    }