如何把桌面上的图标信息读入到一个listview控件中??(见者有分!!)(200分)

  • 主题发起人 主题发起人 001china
  • 开始时间 开始时间
0

001china

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把桌面上的图标信息读入到一个listview控件中,可是苦于没有方法,不知从何入手。
我也知道桌面其实也是一个Syslistview32控件,要求包括桌面上的所有内容,包括“我的电脑”、
“回收站”等等,总之希望同桌面一样了。
还请各位大侠多多指教!!!
帮忙提前者也有分!!
 
一觉醒来,没有一个人回答呀,太伤心了!!
555555555555555555555~~
 
可以只订阅邮件通知,不关注的吗????

我只是想关注
 
有谁知道如何解决,请也通知我一下
 
失望中…………
 
试试这几个API:
ShGetFileInfo
ShGetDesktopFolder
EnumObjects
 
procedure TForm1.Button1Click(Sender: TObject);
var
wnd:Thandle;
begin
wnd:=findwindow('progman',nil);
wnd:=findwindowex(wnd,hwnd(0),'shelldll_defview',nil);
wnd:=findwindowex(wnd,hwnd(0),'syslistview32',nil);
showwindow(wnd,sw_hide);
end;
这段程序可以隐藏掉桌面上的图标,现在的问题是不知道桌面上的图标的类名,如果知道的
话将类名代入,我想可以解决本问题。
 
//我正有这样的程序,能在98下运行,在XP下有问题。 下面是它的片段:
//得到图标的坐标,名称,图标索引
//uses Commctrl,ShellAPI
procedure TForm1.Button1Click(Sender: TObject);
var
h,hFile,hFileMap,hFile2,hFileMap2: THandle;
i,j: integer;
sFileName,sFileName2: string;
pFileMap,pFileMap2: Pointer;
c: TPoint;
aItem: LV_ITEM;
TempDir: Array[0..255] of Char;
begin
h:=FindWindow('Progman','Program Manager');
h:=GetWindow(h,GW_CHILD);
h:=GetWindow(h,GW_CHILD);
Form1.ListView1.Items.Clear;
j:=Listview_GetItemCount(h);
If j = 0 Then exit;
GetTempPath(256, TempDir);
sFileName:=TempDir+'TEMP.1';
hFile:=CreateFile(PChar(sFileName),
GENERIC_READ Or GENERIC_WRITE,
0,
nil,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
hFileMap:=CreateFileMapping(hFile, nil, PAGE_READWRITE, 0, 40, 'MyMapping');
pFileMap:=MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
sFileName2:=TempDir+'TEMP.2';
hFile2:=CreateFile(PChar(sFileName2),
GENERIC_READ Or GENERIC_WRITE,
0,
nil,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
hFileMap2:=CreateFileMapping(hFile2, nil, PAGE_READWRITE,0, 40, 'MyMapping2');
pFileMap2:=MapViewOfFile(hFileMap2, FILE_MAP_WRITE, 0, 0, 0);
for i:=0 to j-1 do
begin
ListView1.Items.Add;
ListView1.Items.Item.Caption:=inttostr(i);
SendMessage(h, LVM_GETITEMPOSITION, i, LPARAM(pFileMap));
CopyMemory(@c, pFileMap, 8);
ListView1.Items.Item.SubItems.Add(inttostr(c.x));
ListView1.Items.Item.SubItems.Add(inttostr(c.y));

aItem.mask:=LVIF_TEXT;
aItem.iItem:=i;
aItem.pszText:=pFileMap2;
aItem.cchTextMax:=40;
CopyMemory(pFileMap, @aItem, 40);
SendMessage(h, LVM_GETITEMTEXT, i, LPARAM(pFileMap));
CopyMemory(@aItem, pFileMap, 40);
ListView1.Items.Item.SubItems.Add(aItem.pszText);

aItem.mask:=LVIF_IMAGE;
aItem.iItem:=i;
aItem.pszText:=pFileMap2;
aItem.cchTextMax:=40;
CopyMemory(pFileMap, @aItem, 40);
SendMessage(h, LVM_GETITEM, i, LPARAM(pFileMap));
CopyMemory(@aItem, pFileMap, 40);
ListView1.Items.Item.SubItems.Add(inttostr(aItem.iImage));
end;
FlushViewOfFile(pFileMap, 40);
UnmapViewOfFile(pFileMap);
CloseHandle(hFileMap);
CloseHandle(hFile);
FlushViewOfFile(pFileMap2, 40);
UnmapViewOfFile(pFileMap2);
CloseHandle(hFileMap2);
CloseHandle(hFile2);
End;
 
gbh能否将你的程序详细注释一下
 
在d6中你用shelllistview不就可以了吗?
 
你去桌面的目录里找不就可以了?
 
>>>见者有分
我是见者
 
扫描桌面文件夹是不行的,“我的电脑”,“ie”等图标只在桌面上有
 
冲着得分来的,
帮你考虑一下!
 
LVM_ARRANGE ListView_Arrange
LVM_CREATEDRAGIMAGE ListView_CreateDragImage
LVM_DELETEALLITEMS ListView_DeleteAllItems
LVM_DELETECOLUMN ListView_DeleteColumn
LVM_DELETEITEM ListView_DeleteItem
LVM_EDITLABEL ListView_EditLabel
LVM_ENSUREVISIBLE ListView_EnsureVisible
LVM_FINDITEM ListView_FindItem
LVM_GETBKCOLOR ListView_GetBkColor
LVM_GETCALLBACKMASK ListView_GetCallbackMask
LVM_GETCOLUMN ListView_GetColumn
LVM_GETCOLUMNWIDTH ListView_GetColumnWidth
LVM_GETCOUNTPERPAGE ListView_GetCountPerPage
LVM_GETEDITCONTROL ListView_GetEditControl
LVM_GETIMAGELIST ListView_GetImageList
LVM_GETISEARCHSTRING ListView_GetISearchString
LVM_GETITEM ListView_GetItem
LVM_GETITEMCOUNT ListView_GetItemCount
LVM_GETITEMPOSITION ListView_GetItemPosition
LVM_GETITEMRECT ListView_GetItemRect
LVM_GETITEMSPACING ListView_GetItemSpacing
LVM_GETITEMSTATE ListView_GetItemState
LVM_GETITEMTEXT ListView_GetItemText
LVM_GETNEXTITEM ListView_GetNextItem
LVM_GETORIGIN ListView_GetOrigin
LVM_GETSELECTEDCOUNT ListView_GetSelectedCount
LVM_GETSTRINGWIDTH ListView_GetStringWidth
LVM_GETTEXTBKCOLOR ListView_GetTextBkColor
LVM_GETTEXTCOLOR ListView_GetTextColor
LVM_GETTOPINDEX ListView_GetTopIndex
LVM_GETVIEWRECT ListView_GetViewRect
LVM_HITTEST ListView_HitTest
LVM_INSERTCOLUMN ListView_InsertColumn
LVM_INSERTITEM ListView_InsertItem
LVM_REDRAWITEMS ListView_RedrawItems
LVM_SCROLL ListView_Scroll
LVM_SETBKCOLOR ListView_SetBkColor
LVM_SETCALLBACKMASK ListView_SetCallbackMask
LVM_SETCOLUMN ListView_SetColumn
LVM_SETCOLUMNWIDTH ListView_SetColumnWidth
LVM_SETIMAGELIST ListView_SetImageList
LVM_SETITEM ListView_SetItem
LVM_SETITEMCOUNT ListView_SetItemCount
LVM_SETITEMPOSITION ListView_SetItemPosition
LVM_SETITEMPOSITION32 ListView_SetItemPosition32
LVM_SETITEMSTATE ListView_SetItemState
LVM_SETITEMTEXT ListView_SetItemText
LVM_SETTEXTBKCOLOR ListView_SetTextBkColor
LVM_SETTEXTCOLOR ListView_SetTextColor
LVM_SORTITEMS ListView_SortItems
LVM_UPDATE ListView_Update
等commctrl单元的API或消息!有些可能需要用到共享内存区!
 
请留下地址, 我好发完整的程序。
 
感谢gbh,我的地址:001china@21cn.com
 
程序已经收到了,非常感谢,不过不知如何来运行其中得到桌面上的软件呢??
比如“我的电脑”等等!!
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部