According to the documentation for winId, the returned value is platform dependent.
So for Windows, it surely must (famous last words), return a hwnd
and thus need no further conversion. If so, then try:
QPixmap.grabWindow(hwnd).save(filename, 'jpg')
(PS: I have actually tested this now on WinXP, and it works okay for me).