我用C#编写一个程序来获取任务栏中的文件夹(也就是说,这个程序能够知道电脑上哪些文件夹被打开),而且可以得这些文件夹的路径,当有新的文件夹打开时马上获取这个新打开的文件夹的路径,也就是能实时监控。比如说windows任务管理器的“应用程序”中就可以看到哪些文件夹被打开了。请问C#能实现这样的功能吗?
解决方案 »
- Wince SQLce 数据库连接的怪事
- 关于打印【很简单】
- 基类 屏蔽 子类事件
- Dictionary.Add 问题???
- 请教如果把窗体的Opacity属性设置为0%,如何让上面的控件不透明?
- 在C#中,下面的程序中,cw为什么不能声明为static类型的
- “Excel.Application.Application()”表示“方法”,它在给定的上下文中无效,是什么原因?
- 求一个算法,生成5位序号
- 新手学习,Xtra TreeList数据绑定问题
- 有了DataRow为什么还要有DataRowBuilder?
- 反射相关的问题,如何实例化?
- 急!急!急!急!急!gridview中显示多次查询结果有人会吗?
private void Form2_Load(object sender, EventArgs e)
{
EnumWindowsProc _EunmWindows = new EnumWindowsProc(NetEnumWindows);
EnumWindows(_EunmWindows, 0); for (int i = 0; i != m_ViewDirectoryPath.Count; i++)
{
MessageBox.Show(m_ViewDirectoryPath[i]);
}
} [DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int GetClassName(IntPtr hWnd, out STRINGBUFFER ClassName, int nMaxCount); [DllImport("user32.dll")]
public static extern bool IsWindowVisible(IntPtr hWnd); [DllImport("user32.dll")]
public static extern int EnumChildWindows(IntPtr hWndParent, EnumWindowsProc ewp, int lParam); [DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, StringBuilder lParam); [DllImport("user32.dll")]
public static extern int EnumWindows(EnumWindowsProc ewp, int lParam); public delegate bool EnumWindowsProc(IntPtr p_Handle, int p_Param);
private List<string> m_ViewDirectoryPath = new List<string>(); [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct STRINGBUFFER
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)]
public string szText;
} private bool NetEnumWindows(IntPtr p_Handle, int p_Param)
{
if (!IsWindowVisible(p_Handle)) return true; STRINGBUFFER _ClassName = new STRINGBUFFER();
GetClassName(p_Handle, out _ClassName, 255); if(_ClassName.szText.Trim()=="CabinetWClass")
{
EnumWindowsProc _EunmControl = new EnumWindowsProc(NetEnumControl);
EnumChildWindows(p_Handle, _EunmControl, 0);
}
return true;
}
private bool NetEnumControl(IntPtr p_Handle, int p_Param)
{
STRINGBUFFER _ClassName = new STRINGBUFFER();
GetClassName(p_Handle, out _ClassName, 255);
if (_ClassName.szText == "Edit")
{
StringBuilder _TextStringA = new StringBuilder(1024);
SendMessage(p_Handle, 0x000D, 1024, _TextStringA);
m_ViewDirectoryPath.Add(_TextStringA.ToString());
}
return true;
}
这个意思?
等我看看你的代码,另外
WMI是做什么的啊?