EnumWindows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could anyone explain to me why this code doesn't work:

[DllImport("coredll.dll")]
private static extern bool EnumWindows(EnumWindowsProc func, int lParam);

public delegate bool EnumWindowsProc(int hWnd, int lParam);


private static bool EnumWnds(int hWnd, int lParam)
{
return true;
}


private void function()
{
EnumWindowsProc ef = new EnumWindowsProc(EnumWnds);

EnumWindows(ef, 0);
}

EnumWindows causes an exception...

Thank you.
 
I was browsing around on this subject the other week. You might want to
check out Alex Feinmans rather clever implementation of callbacks

http://www.alexfeinman.com/Callbacks/Callbacks.htm
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/opennetcf/Callbacks/

It actually didn't work for me out of the box on ARM4, I'm going to dig
deeper when really need it.


Sergey Bogdanov said:
Sorry, but P/Invoke service on Compact Framework does not support
callbacks (as it does Full Framework through the use of delegates). To
read more about differences between Full and Compact Framework see
http://msdn.microsoft.com/library/en-us/dnnetcomp/html/netcfintrointerp.asp

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Could anyone explain to me why this code doesn't work:

[DllImport("coredll.dll")]
private static extern bool EnumWindows(EnumWindowsProc func, int lParam);

public delegate bool EnumWindowsProc(int hWnd, int lParam);


private static bool EnumWnds(int hWnd, int lParam)
{
return true;
}


private void function()
{
EnumWindowsProc ef = new EnumWindowsProc(EnumWnds);

EnumWindows(ef, 0);
}

EnumWindows causes an exception...

Thank you.
 
Thanks for both answers and thanks for the links. I'm working on a ARM4 too,
so i'm afraid it won't work out of the box. Anyway i'll try and let you know.
 
It is possible to implement the functionality of the EnumWindows by using
GetWindow and GetWindowText. I'll try to put together a sample and post it on
my blog.

-Alex
 
Right that's a good idea. With the parameters GW_HWNDFIRST and GW_HWNDNEXT
it should easily work. Let's try that.
 
Back
Top