453635970 发表于 2014-10-8 17:14:34

桌面快捷方式位置设置程序

本帖最后由 453635970 于 2014-10-8 18:02 编辑

**** Hidden Message *****可以移动桌面快捷方式的位置 以下是部分代码呵呵

可以采用 远程线程注入的办法。 下面是部分关键代码
demo 程序下载地址: http://pan.baidu.com/s/1jGgg3oM
代码下载地址: **** Hidden Message *****
获取桌面的图标编号
void GetIconNum(int& num, char* pName)
{
HWND hwndParent=::FindWindow(_T("Progman"),NULL);
HWND hwndSHELLDLL_DefView=::FindWindowEx(hwndParent,NULL,_T("SHELLDLL_DefView"),NULL);
HWND hwndSysListView32=::FindWindowEx(hwndSHELLDLL_DefView,NULL,_T("SysListView32"),_T("FolderView"));
int iMaxCount=ListView_GetItemCount(hwndSysListView32);//图标数
DWORD dwPid;
GetWindowThreadProcessId(hwndSysListView32,&dwPid);//获取进程ID
HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,dwPid);//打开进程
if (hProcess==INVALID_HANDLE_VALUE)//打开进程失败
return;
LVITEM*plvitem=(LVITEM*)VirtualAllocEx(hProcess, NULL, sizeof(LVITEM),MEM_COMMIT, PAGE_READWRITE);//在目标进程内分配一块小内存
TCHAR *pszName=(TCHAR*)VirtualAllocEx(hProcess, NULL, MAX_PATH*sizeof(TCHAR),MEM_COMMIT, PAGE_READWRITE);//分配名字
POINT *ppt=(POINT*)VirtualAllocEx(hProcess, NULL, sizeof(POINT),MEM_COMMIT, PAGE_READWRITE);//获取坐标用
TCHAR szName="";
for (int i=0;i<iMaxCount;i++)
{
//ListView_GetItemText(hwndSysListView32, i, 0, szName,sizeof(szName));//获取图标名称
LVITEM lv={0};
lv.cchTextMax=MAX_PATH*sizeof(TCHAR);
lv.pszText=pszName;
WriteProcessMemory(hProcess, plvitem, &lv,sizeof(LVITEM), NULL);//把信息写入
SendMessage(hwndSysListView32, LVM_GETITEMTEXT, i,(LPARAM)plvitem);//发送消息
ReadProcessMemory(hProcess, pszName, szName, sizeof(szName), NULL);//读取名字
if (stricmp(pName, szName)==0)
{
   num = i;
   break;
}
//POINT pt;
/////ListView_GetItemPosition(hwndLv, i, &pt);//获取图标所在坐标
//SendMessage(hwndSysListView32,LVM_GETITEMPOSITION,i,(LPARAM)ppt);
//ReadProcessMemory(hProcess,ppt,&pt,sizeof(POINT),NULL);//读取图标坐标
}
VirtualFreeEx(hProcess, plvitem, 0, MEM_RELEASE);//释放内存
VirtualFreeEx(hProcess, pszName, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, ppt, 0, MEM_RELEASE);
CloseHandle(hProcess);
//::SendMessage(hwndSysListView32,LVM_SETITEMPOSITION,num,MAKELPARAM(x,y));
//ListView_RedrawItems(hwndSysListView32, 0, ListView_GetItemCount(hwndSysListView32)-1);
//::UpdateWindow(hwndSysListView32);
}
//设置图标位置
void SetIconPosition(int x,int y,int num)
{
HWND hwndParent=::FindWindow("Progman",NULL);
HWND hwndSHELLDLL_DefView=::FindWindowEx(hwndParent,NULL,"SHELLDLL_DefView",NULL);
HWND hwndSysListView32=::FindWindowEx(hwndSHELLDLL_DefView,NULL,"SysListView32","FolderView");
//移除掉自动排序风格
SetWindowLong(hwndSysListView32, GWL_STYLE, GetWindowLong(hwndSysListView32, GWL_STYLE) ^ LVS_AUTOARRANGE);
::SendMessage(hwndSysListView32,LVM_SETITEMPOSITION,num,MAKELPARAM(x,y));
ListView_RedrawItems(hwndSysListView32, 0, ListView_GetItemCount(hwndSysListView32)-1);
::UpdateWindow(hwndSysListView32);
//SetWindowLong(hwndSysListView32, GWL_STYLE, GetWindowLong(hwndSysListView32, GWL_STYLE) | LVS_AUTOARRANGE);
}


Angel丶L 发表于 2014-10-8 19:16:13

之下,

大个的糖果 发表于 2014-11-1 04:21:12

kidddd 发表于 2015-10-9 11:45:33

ddddddddddddddd

waliemiao 发表于 2015-10-14 03:01:14

看看

mehelloworld 发表于 2015-10-30 23:20:52

zx6863669 发表于 2016-2-29 12:54:17

看看学习

MagicJade 发表于 2017-3-23 17:20:54

看看

finch7 发表于 2018-3-21 18:27:10

赞,真不错帮大忙了,看看

w2671641895 发表于 2018-12-27 16:38:54

谢谢,我很需要这个东西,拿走学习,感谢

My_A 发表于 2019-2-20 23:57:35

666
页: [1]
查看完整版本: 桌面快捷方式位置设置程序