在C#2003中如何得到System.Drawing.Icon的句柄??
比如我现在实例化System.Drawing.Icon icon,然后,无法得到icon的句柄!请问
该如何得到??

解决方案 »

  1.   

    private int GetWin32IntConstant(string name)
    {
        System.Reflection.Assembly asm = 
        System.Reflection.Assembly.GetAssembly(typeof(com.ms.win32.wina));
        Type t = asm.GetType("com.ms.win32.win" + char.ToLower(name[0]), 
                             true);
        System.Reflection.FieldInfo info = t.GetField(name);
        return int.Parse(info.GetValue(null).ToString());
    }
      

  2.   

    to godgreat:那样就可以得到 System.Drawing.Icon icon的句柄了??hbxtlhx(平民百姓-自已动手,丰衣足食) : 2003里帮助Icon里有Handle属性,但System.Drawing.Icon 就是调不出来
      

  3.   

    有的吧,这样不行吗?System.Drawing.Icon icon;
    IntPtr handle = icon.Handle;
      

  4.   

    TO godgreat:谢谢TO hbxtlhx:MSDN上C#2003上是有Handle属性的,但这个System.Drawing.Icon调不出来不知为什么??
      

  5.   

    To hbxtlhx:net2003里,就是出不来 
       System.Drawing.Icon icon;
       IntPtr handle = icon.Handle;也不行
      

  6.   

    Z:\NotifyClient\NotifyIcon.cs(61): “System.Drawing.Icon”并不包含对“Handle”的定义
    报这样的错
      

  7.   

    我安装了VS2003,并且使用了如下的语句测试完全没有问题:System.Drawing.Icon icon=SystemIcons.Application;
    IntPtr handle = icon.Handle;
    Console.WriteLine(handle);输出为:
    65539
      

  8.   

    To godgreat:那个方法在net2003中不能用TO hbxtlhx:我试试,后面是SystemIcons.Application;对吧?
      

  9.   

    TO hbxtlhx:我现在是建的一个PPC的类,没有Application,我加个窗体看看行不行
      

  10.   

    TO hbxtlhx:net精简版好像不支持。我试了,在windows程序下可以调用Handle,但做智能设备程序就出不来了
      

  11.   

    Icon.Handle 属性  [C#]请参见
    Icon 类 | Icon 成员 | System.Drawing 命名空间 | Icon 成员(Visual J# 语法) | C++ 托管扩展编程 
    要求
    平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列
    语言
    C#C++JScriptVisual Basic全部显示
    获取此 Icon 对象的 Windows 句柄。这并非该句柄的副本;请不要释放它。[Visual Basic]
    Public ReadOnly Property Handle As IntPtr[C#]
    public IntPtr Handle {get;}[C++]
    public: __property IntPtr get_Handle();[JScript]
    public function get Handle() : IntPtr;属性值
    该图标的 Windows 句柄。
    //here
    要求
    平台: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 系列
      

  12.   

    我这个类主要是想实现PPC上的托盘图标,其他思路只有再想了,谢谢各位