using Microsoft.Win32; using System.Security.Permissions; [assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, ViewAndModify="HKEY_CURRENT_USER")] Registry.LocalMachine.CreateSubKey(...).SrtValue(...)
没用过w7,所以给不了了。 你调试一下程序,也就是那几个api。应该可以用的。
IntPtr desktopHwnd = GetDesktopPtr(); IntPtr ownHwnd = new WindowInteropHelper(this).Handle; IntPtr result = Win32.SetParent(ownHwnd, desktopHwnd);
using System.Security.Permissions;
[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum, ViewAndModify="HKEY_CURRENT_USER")]
Registry.LocalMachine.CreateSubKey(...).SrtValue(...)
你调试一下程序,也就是那几个api。应该可以用的。
IntPtr desktopHwnd = GetDesktopPtr();
IntPtr ownHwnd = new WindowInteropHelper(this).Handle;
IntPtr result = Win32.SetParent(ownHwnd, desktopHwnd);
private IntPtr GetDesktopPtr() {
//http://blog.csdn.net/mkdym/article/details/7018318
// 情况一
IntPtr hwndWorkerW = IntPtr.Zero;
IntPtr hShellDefView = IntPtr.Zero;
IntPtr hwndDesktop = IntPtr.Zero;
IntPtr hProgMan = Win32.FindWindow("ProgMan", null);
if (hProgMan != IntPtr.Zero) {
hShellDefView = Win32.FindWindowEx(hProgMan, IntPtr.Zero, "SHELLDLL_DefView", null);
if (hShellDefView != IntPtr.Zero) {
hwndDesktop = Win32.FindWindowEx(hShellDefView, IntPtr.Zero, "SysListView32", null);
}
}
if (hwndDesktop != IntPtr.Zero) return hwndDesktop; // 情况二
while (hwndDesktop == IntPtr.Zero) {//必须存在桌面窗口层次
hwndWorkerW = Win32.FindWindowEx(IntPtr.Zero, hwndWorkerW, "WorkerW", null);//获得WorkerW类的窗口
if (hwndWorkerW == IntPtr.Zero) break;//未知错误
hShellDefView = Win32.FindWindowEx(hwndWorkerW, IntPtr.Zero, "SysListView32", null);
if (hShellDefView == IntPtr.Zero) continue;
hwndDesktop = Win32.FindWindowEx(hShellDefView, IntPtr.Zero, "SysListView32", null);
}
return hwndDesktop;
}
如果第二个参数是HWND_BOTTOM不知道会有啥效果
- -!、、貌似 楼主要的是 镶嵌到桌面 那就 用setParent吧 不过、、
如六楼 去找桌面的listview控件 然后镶嵌进去、、、
用SPY++自己试试,XP已经很久没碰了,帮不到你