FindWindow fails
Question: I've troubles with `FindWindow` using `pywin32` extension. Simple C code:

    
    
    int main()
    {
      HWND h = FindWindow(NULL, TEXT("SomeApp"));
      if (h != INVALID_HANDLE_VALUE)
          SetForegroundWindow(h);
      return 0;
    }
    

Works well. Same with python:

    
    
    import win32gui
    
    h = win32gui.FindWindow(None, "SomeApp")
    if h:
        win32gui.SetForegroundWindow(h)
    else:
        print "SomeApp not found"
    

Fails, SomeApp not found. I suggest text encoding may be cause trouble here
but not found any information in docs how to specify text.

**Update:** I've tested code on other machine and don't see any troubles. So,
configuration on my first machine should be incorrect. I've update my
investigation results if found the problem.


Answer: In the C code, you are checking `h != INVALID_HANDLE_VALUE`, in Python `h !=
None`. `INVALID_HANDLE_VALUE` is not `0`/`null`/`None`.

Python defines `win32file.INVALID_HANDLE_VALUE` via the `win32file` import.

Also, instead of printing "SomeApp not found", you can do something like:

    
    
    gle = win32api.GetLastError()
    err = win32api.FormatMessage(gle)[:-2]
    print 'SomeApp not found: LastError=%d - %s' % (gle, err)
    

This should give you more details on the failure if `FindWindow` has
legitimately failed for some reason (or "Success" if it worked).

