How to get the X- and Y-coordinates of Desktop icons (Views: 100)


Does anyone know where the X- and Y-coordinates of the icons on the Windows Desktop are stored/ saved and how I can read and write those values?


Since the desktop is a simple ListView (embedded in a few other windows), you'll be able to find it with this (from a little utility of mine). It uses IPCThrd.pas from the IPCXXX demos in the demos directory, for the SharedMem class. You'll have to use that, since otherwise you won't be able to read the information from desktop's memory into your memory.

  PInfo = ^TInfo;
  TInfo = packed record
    infoPoint: TPoint;
    infoText: array[0..255] of Char;
    infoItem: TLVItem;
    infoFindInfo: TLVFindInfo;


  Info: PInfo;
  IniFile: TRegIniFile;
  Wnd: HWnd;
  Count, I: Integer;
  SharedMem: TSharedMem;
  {Find list view window}
  Wnd := FindWindowEx(GetDesktopWindow, 0, 'Progman', 'Program Manager');
  Wnd := FindWindowEx(Wnd, 0, 'SHELLDLL_DefView', nil);
  Wnd := FindWindowEx(Wnd, 0, 'SysListView32', nil);
  Count := ListView_GetItemCount(Wnd);
  SharedMem := TSharedMem.Create('', SizeOf(TInfo));
  Info := SharedMem.Buffer;
  with Info^ do
    infoItem.pszText := infoText;
    infoItem.cchTextMax := 255;
    infoItem.mask := LVIF_TEXT;
    IniFile := TRegIniFile.Create('Software\YaddaYadda');
      with IniFile do
        EraseSection('Desktop\' + CurRes);
        for I := 0 to Count - 1 do
          infoItem.iItem := I;
            ListView_GetItem(Wnd, infoItem);
            ListView_GetItemPosition(Wnd, I, infoPoint);
            WriteString('Desktop\' + CurRes, infoText, Format('%.4d, %.4d', [Point.X,

<< Back to main page