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;

	return 0;
9 Years
Discussion Span
Last Post by Ancient Dragon

>>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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.