怎么用api设置桌面图标自动排列为false,还有自动隐藏??希望大家给想想,急用!!!
 

解决方案 »

  1.   

    http://www.applevb.com/sourcecode/deskicon.zip
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace 隐藏显示桌面或任务栏
    {
        public partial class Form1 : Form
        {
            [DllImport("user32.dll", EntryPoint = "FindWindow")]
            public static extern int FindWindow(
                string lpClassName,
                int lpWindowName
            );        [DllImport("user32.dll", EntryPoint = "ShowWindow")]
            public static extern int ShowWindow(
                int hwnd,
                int nCmdShow
            );        [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
            public static extern int FindWindowEx(
                int hWnd1,
                int hWnd2,
                string lpsz1,
                int lpsz2
            ); 
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {        }        private void button1_Click(object sender, EventArgs e)
            {
                int hwnd,child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                ShowWindow(child, 0);
            }        private void button2_Click(object sender, EventArgs e)
            {
                int hwnd, child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                ShowWindow(child,1);
            }
        }
    }
      

  3.   

    给你个VBS的
    http://www.mybat.cn/forum/viewthread.php?tid=908
      

  4.   

    参考一些其它人的
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        [DllImport("user32.dll", EntryPoint = "FindWindow")]
            public static extern int FindWindow(
                string lpClassName,
                int lpWindowName
            );        [DllImport("user32.dll", EntryPoint = "ShowWindow")]
            public static extern int ShowWindow(
                int hwnd,
                int nCmdShow
            );        [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
            public static extern int FindWindowEx(
                int hWnd1,
                int hWnd2,
                string lpsz1,
                int lpsz2
            );         [DllImport("user32.dll")]
            public static extern int SetWindowLong(
                IntPtr hwnd,
                int nIndex,
                int dwNewLong
                );
            [DllImport("user32.dll")]
            public static extern int GetWindowLong(IntPtr hWnd,
                int nIndex);        private void HideIcon(object sender, EventArgs e)
            {
                int hwnd,child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                ShowWindow(child, 0);
            }        private void ShowIcon(object sender, EventArgs e)
            {
                int hwnd, child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                ShowWindow(child,1);
            }        const int GWL_STYLE = -16;
            const int LVS_AUTOARRANGE = 0x0100;        private void DisableAutoArrange(object sender, EventArgs e)
            {
                int hwnd, child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                int oldValue=GetWindowLong(new IntPtr(child),GWL_STYLE);
                SetWindowLong(new IntPtr(child), GWL_STYLE, oldValue & ~LVS_AUTOARRANGE);
            }        private void EnableAutoArrange(object sender, EventArgs e)
            {
                int hwnd, child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                int oldValue = GetWindowLong(new IntPtr(child), GWL_STYLE);
                SetWindowLong(new IntPtr(child), GWL_STYLE, oldValue & LVS_AUTOARRANGE);
            }
        }
    }
      

  5.   

    更改auto arrange不能反映在菜单上 但可以拖动图标检查效果
      

  6.   

    我试了试,怎么不行啊~~
    调用EnableAutoArrange这个方法,怎么连桌面图标都不能拖动了啊~
    对了,楼上,我说错了应该是“自动排列”和“对齐到网格”
    再给说一下好吗?
    分给定你了~~
      

  7.   

    EnableAutoArrange后确实不能拖动图标 要不怎么自动排列
    下边是对齐到网格的代码
    const int LVM_First = 0x1000;
            const int LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_First + 54;
            const int LVS_EX_SNAPTOGRID = 0x00080000;        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
            public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);        private void EnableAlignToGrid(object sender, EventArgs e)
            {
                int hwnd, child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                SendMessage(new IntPtr(child), LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_SNAPTOGRID), new IntPtr(LVS_EX_SNAPTOGRID));
            }        private void DisableAlignToGrid(object sender, EventArgs e)
            {
                int hwnd, child;
                hwnd = FindWindow("progman", 0);
                hwnd = FindWindowEx(hwnd, 0, "shelldll_defview", 0);
                child = FindWindowEx(hwnd, 0, "SysListView32", 0);
                SendMessage(new IntPtr(child), LVM_SETEXTENDEDLISTVIEWSTYLE, new IntPtr(LVS_EX_SNAPTOGRID), IntPtr.Zero);
            }
      

  8.   

    对齐网格很正确啊!!
    谢谢,Macosx了
    你真厉害啊~~
      

  9.   

    借楼主一个光,想请问一下大虾们,在哪里有C#的WinApi资料?