1

I have a simple program that uses FindWindowEx & strncmp() inside a callback passed to EnumChildWindows, to find a dialog created by a third party application, and press a button.

This code works fine on my Windows 7 Ultimate PC, but if I run it on Windows Server 2003 it no longer works.

I have used Spy++ and the window captions and text are identical. Is there something I am missing about Server 2003 which may break this? (DEP and UAC are off, this is is a test PC; I am also running this inside an RDP session)

This is my call to FindWindowEx:

parentWindow = FindWindowEx(NULL,NULL,NULL,(LPCSTR)caption);

With caption being a (TCHAR[]) constant.

sebf
  • 2,831
  • 5
  • 32
  • 50
  • 1
    Remove the (LPCSTR) cast, it is *never* correct. If you now get a compile error then you are getting somewhere. Use FindWindowsExA() if necessary. – Hans Passant Jun 30 '11 at 16:52
  • @Hans, Thanks for the correction! I am updating it now. – sebf Jul 01 '11 at 12:59

2 Answers2

1

Is the third party application a service? Windows services can run under a different session than a user logged in via RDP, so a UI created by an interactive service would appear on a different window station (and therefore a different desktop, which is why you couldn't find it).

tinman
  • 6,348
  • 1
  • 30
  • 43
  • Hi! No it is running in the 'local' session. I know this because its acctually hooked (successfully) but another program that runs parallel to mine and I think works in a similar way. – sebf Jul 01 '11 at 12:59
0

Solved.

@sebf: Its 2011; support Unicode, idiot!

sebf
  • 2,831
  • 5
  • 32
  • 50