获取桌面图标的名称
#include <Windows.h>
#include <tchar.h>
#include "Commctrl.h"
#include <iostream>
#include <string>
using namespace std;
#define ALLOC_SIZE 200
//取桌面 ListView 的句柄
string OnSetDeskIcon()
{
HWND hDeskTop;
DWORD dwPID;
HANDLE hProcess;
LPVOID pData;
LPVOID pString;
LVITEM lvi;
//BOOL fResult;
//SIZE_T BytesRead;
//SIZE_T BytesWritten;
char szText[ALLOC_SIZE];
hDeskTop = FindWindow(_T("progman"), NULL);
hDeskTop = FindWindowEx(hDeskTop, 0, _T("shelldll_defview"), NULL);
hDeskTop = FindWindowEx(hDeskTop, 0, _T("syslistview32"), NULL);
int count = ListView_GetItemCount(hDeskTop);
// get desktop window process ID (explorer.exe)
GetWindowThreadProcessId(hDeskTop, &dwPID);
// open process to get explorer process handle
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPID);
// allocate memory in explorer's address space
// allocate space for LVITEM struct
pData = VirtualAllocEx(hProcess, NULL, ALLOC_SIZE, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
// allocate space for string (i.e. "Network Neighborhood")
pString = VirtualAllocEx(hProcess, NULL, ALLOC_SIZE, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
// init LV_ITEM struct
ZeroMemory(&lvi, sizeof(LVITEM));
//lvi.iItem = 0;
lvi.cchTextMax = 500;
// write the contents of lvi into explorer's address space
for(int i = 0; i < count; i++)
{
// get item's name
lvi.iSubItem = 0;
lvi.pszText = (LPWSTR)pString;
WriteProcessMemory(hProcess, pData, &lvi, sizeof(LVITEM),NULL);
::SendMessage(hDeskTop, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)pData);
// read back lvi struct (for debugging purposes only)
//ReadProcessMemory(hProcess, pData, szText, ALLOC_SIZE, &BytesRead);
// read text of queried item
ReadProcessMemory(hProcess, pString, szText, ALLOC_SIZE,NULL);
}
VirtualFreeEx(hProcess, pString, ALLOC_SIZE, MEM_DECOMMIT);
VirtualFreeEx(hProcess, pData, ALLOC_SIZE, MEM_DECOMMIT);
CloseHandle(hProcess);
string s = szText;
return s;
}
int main()
{
//int n = OnSetDeskIcon();
//cout << n << endl;
//cout <<
string s = OnSetDeskIcon();
cout << s;
}
只能显示图标数量,不能显示名称
...全文
相关推荐
易语言-易语言获取桌面图标名称与坐标
易语言获取桌面图标名称与坐标源码
桌面图标名称与坐标获取技术详解及实践
为了在程序中获取图标名称,可以使用Windows Shell扩展提供的API。和IShellLink等接口提供了丰富的功能来操作快捷方式文件。通过这些接口,可以访问和修改快捷方式的属性,包括图标名称。// C# 示例代码if (verbs!= null)// 这里可以进一步操作获取图标名称等属性。
delphi 获取桌面图标坐标及名称
昨天 看到 Chrome 浏览器 旁弹出了 一个 双十一的 广告: 后分析 是 QQ拼音输入法弹出的,然后联想到自己 实现一个,先找到浏览器的坐标吧 先用c++ 实现了一遍 然后 翻译成delphi,在学C++ ,delphi快没饭吃了,但还是想着,哈哈 uses Winapi.CommCtrl; //x64 x86 = LVITEM type tagLVITEM64A = record mask: UINT; iItem: Integer; iSu...
易语言获取桌面图标名称与坐标源码-易语言
易语言获取桌面图标名称与坐标源码
易语言获取桌面图标名称与坐标源码
易语言获取桌面图标名称与坐标源码。@学而不思零。


进程/线程/DLL

