Im a beginning C++ programmer and i was just trying out some of the awsome stuff that can be done with c++ and not VB(.NET, 2008).
I actualy have 2 questions:

First, y does this give me an empty console screen?
Im not getting any error messages, my intend was to get all icons on the desktop and do some wacky stuff with them.

Second, will this get me all the items on the desktop ?

#include <iostream>
#include <windows.h>
#include <commctrl.h>


int Main()
{
	using namespace std;

	LVITEM* Item = new LVITEM;
	Item->iSubItem = 0;
	Item->cchTextMax = 255;
	Item->pszText = NULL;

	HWND desktop;
	do{desktop = FindWindow(NULL,L"program");}while(desktop = NULL);
	do{desktop = FindWindowEx(desktop, 0, L"SHELLDLL_DefView", NULL);}while(desktop = NULL);
	do{desktop = FindWindowEx(desktop, 0, L"SysListView32", NULL);}while(desktop = NULL);

	int totalItem = SendMessage(desktop, LVM_GETITEMCOUNT, 0, 0);

	for(int i = 0; i < totalItem; i++)
	{
		 SendMessage(desktop, LVM_GETITEMTEXT, i, (long)Item);
		 cout << Item->pszText << endl;
	}
	cin.get();

	return 0;
}

Recommended Answers

All 2 Replies

>>while(desktop = NULL);
That will produce an infinite loop because you want to use the boolean == operator, not the assignment = operator.

And what's the point of those do loops anyway? If FindWindow() returns NULL the first time it will always return NULL. Calling FindWindow() again isn't going to change the return value.

>> pointless post - cartman714
You obviously have no clue about what I posted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.