c# 获取windows桌面图标 张宇轩

本文提供了一段C#代码示例,用于获取Windows桌面图标的名称和位置。通过调用Windows API函数,如FindWindow、SendMessage等,实现对桌面图标列表视图的操作,读取图标文本并定位其屏幕位置。
摘要由CSDN通过智能技术生成

using System.Runtime.InteropServices;
       public const uint LVM_FIRST = 0x1000;
      public const uint LVM_GETITEMCOUNT = LVM_FIRST + 4;
      public const uint LVM_GETITEMW = LVM_FIRST + 75;
      public const uint LVM_GETITEMPOSITION = LVM_FIRST + 16;
       [DllImport("user32.DLL")]
      public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam,
      int lParam);
      [DllImport("user32.DLL")]
      public static extern IntPtr FindWindow(string lpszClass, string
      lpszWindow);
      [DllImport("user32.DLL")]
      public static extern IntPtr FindWindowEx(IntPtr hwndParent,
          IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
      [DllImport("user32.dll")]
      public static extern uint GetWindowThreadProcessId(IntPtr hWnd,
          out uint dwProcessId);
       public const uint PROCESS_VM_OPERATION = 0x0008;
      public const uint PROCESS_VM_READ = 0x0010;
      public const uint PROCESS_VM_WRITE = 0x0020;
       [DllImport("kernel32.dll")]
      public static extern IntPtr OpenProcess(uint dwDesiredAccess,
          bool bInheritHandle, uint dwPr

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值