I have the code to return a file name/path for a window:

''''''''''''
Dim ModuleName As String, FileName As String, hInst As Long, hWnd As Long

ModuleName = String$(128, Chr$(0))

hWnd = FindWindow("class name", vbNullString)

hInst = GetWindowWord(hWnd, GWW_HINSTANCE) ' -6

ModuleName = Left$(ModuleName, GetModuleFileName(hInst, ModuleName, Len(ModuleName)))

MsgBox ModuleName

'''''''''
However this always returns the path of my program, and NOT the window i want.

hWnd returns a number, no problem there.
But hInst always returns 0.

I think this is the problem, (maybe GWW_HINSTANCE is wrong?), any ideas would be great.

Thanks, David.