Advertisement

07.22.2008 at 05:57AM PDT, ID: 23584904 | Points: 500
[x]
Attachment Details

Get Desktop Icon Text and Position

Asked by marcodalzotto in Windows MFC Programming, C++ Programming Language, Microsoft Visual C++.Net

Tags:

Hi experts,
 I having some difficulties to acces to all the desktop icons info.
I've tried using a DLL, and it works fine. But I discovered a better solution by accessing to the ListCtrl memory with a OpenPocess and VirtualAllocEx functions.

The technique works for the item position, but I'm not able to get the item text.

Can some of you find a solution?

PS: I made a lot of tryings. Please try the code you are going to suggest if you are not secure.

ThanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
HANDLE hProcess = 0;
  POINT *ptVitual = 0;
  char  *ptTitle = 0;
  DWORD wndThreadID;
  DWORD pID;
  int i;
  char title[256];
 
  HWND main    = ::FindWindow("Progman", NULL);
  HWND defView = ::FindWindowEx(main, NULL, "SHELLDLL_DefView", NULL);
  HWND list    = ::FindWindowEx(defView, NULL, "SysListView32", NULL);
 
  wndThreadID = ::GetWindowThreadProcessId(list, &pID);
 
  hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, pID);
  ptTitle = (char  *)VirtualAllocEx(hProcess, NULL, 256, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
  ptVitual = (POINT *)VirtualAllocEx(hProcess, NULL, sizeof(POINT), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
 
  CListCtrl mydesktop;
  mydesktop.Attach(list);
 
  int count = mydesktop.GetItemCount();
  for(i = 0; i < count; i++) {
    // read the item position (this is working)
    mydesktop.GetItemPosition(x, ptVitual);
    ReadProcessMemory(hProcess, ptVitual, &DesktopIcon.pt, sizeof(POINT), NULL);
 
    // read the item text (not working)
    mydesktop.GetItemText(x, 0, ptTitle, 255);
    ReadProcessMemory(hProcess, ptTitle, &title, sizeof DesktopIcon.title, NULL);
 
    // here there is a break to check the title variable content
  }
  mydesktop.Detach();
 
  VirtualFreeEx(hProcess, ptTitle, 256, MEM_RELEASE);
  VirtualFreeEx(hProcess, ptVitual, sizeof(POINT), MEM_RELEASE);
  CloseHandle(hProcess);
  fclose(file);
[+][-]07.22.2008 at 07:30AM PDT, ID: 22059792

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 09:06AM PDT, ID: 22060847

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 02:55AM PDT, ID: 22067483

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 04:11AM PDT, ID: 22067842

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 04:42AM PDT, ID: 22068006

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 01:46AM PDT, ID: 22077106

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628