size : 1561
uploaded_on : Wed Jul 7 00:00:00 1999
modified_on : Wed Dec 8 14:02:50 1999
title : Desktop description
org_filename : DesktopDesc.txt
author : Thorsten Vitt
authoremail : thvitt@gmx.de
description : How to get the description of the desktop on any computer
keywords :
tested : not tested yet
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : plain
file-type : text/plain
category : delphi-system32bit
__END_OF_HEADER__
>How can I get the description of the workspace (e.g. "My computer") and the
>large/small associated icon on any computer?
Hi,
(1) Use the function SHGetSpecialFolderLocation of the Shell-API (unit ShlObj)
var
pidl: PItemIDList;
...
SHGetSpecialFolderLocation(Handle, CSIDL_DRIVES, pidl);
(2) You may use this PIDL with the function SHGetFileInfo ⁿbergeben, which retrieves
a lot of information about this object (also the DisplayName and an icon handle).
var
shfi: TSHFileInfo;
...
SHGetFileInfo(pidl, 0, shfi, SizeOf(shfi), SHGFI_PIDL or
SHGFI_DISPLAYNAME or SHGFI_ICON or SHGFI_SYSICONINDEX or
SHGFI_SMALLICON);
MyIcon.Handle := shfi.hIcon; // MyIcon has to be created first
DisplayName := String(shfi.szDisplayName);
(3) This is how to get system images. First create a TImageList and define
ShareImages:=False (important! SystemIcons will be destroyed else when freeing ImageList!)
var
SystemImageList: TImageList;
SystemImageList := TImageList.Create;
try
SystemImageList.ShareImages := False;
SystemImageList.Handle := SHGetFileInfo('', 0, shfi, SizeOf(shfi),
SHGFI_SYSICONINDEX or SHGFI_SMALLIMAGES);
...
finally
SystemImageList.Free;
end;
(4) Finally you have to free the PIDL wby using the Shell Task Allocator.
procedure SHFreeItemIDList(var pidl: PItemIDList);
var
ppMalloc : IMalloc;
begin
SHGetMalloc(ppMalloc);
ppMalloc.Free(pidl);
end;
SHFreeItemIDList(pidl);
PS: This code is put together from several units, so it may contain minor bugs.