Micro Focus QTP (UFT) Forums

Full Version: "How to Count Desktop Icons"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi Folks,

I have lot of Icons my Desktop, I need total count of icons and verify that particular file/folder/etc are present on my desktop or not?
Hi Suresh,

'get the desktop item count
Code:
intCount=Window("title:=Program Manager").WinListView("object class:=SysListView32").GetItemsCount
msgbox intCount

I am still trying to get the items for validation/verification. I will keep you posted.

Regards,
Ankesh
Hi Ankesh,

First of all thanks for your reply, I tried your code but I got the error like type mismath.
Hi Ankesh,

Sorry for the previous post it's working fine.Now I need to print the name of each icon present on desktop can you please send the code to me.
Hi Suresh,

Usually the below code works fine to get the items

Code:
strItems=Window("title:=Program Manager").WinListView("object class:=SysListView32").GetROProperty("all items")

but for me "all items" property is blank. Can you plz post the snapshot of object spy by spying any of the icon on the desktop?

Regards,
Ankesh
I am not sure of your requirement. You can use VBScript to get this done.
Code:
Set fso = createobject("Scripting.FileSystemObject")
DesktopPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")

'Files count
msgbox fso.GetFolder(DesktopPath).Files.Count

'Folders count
msgbox fso.GetFolder(DesktopPath).SubFolders.Count

'Check if specified file is present
msgbox fso.FileExists(DesktopPath & "\" & "qtp.txt")

'Check if specified folder is present
msgbox fso.FolderExists(DesktopPath & "\" & "DSC_019612")
Hi vIns,

I am getting the count of Desktop Icons but I need the names of Ecah icon present on Desktop.If you know please share code with me and along with Ankesh.