I have a Windows forms application, where I copy files from my filemanager between forms and also to windows environment. I have no problem with copying files to any kind of folders, except desktop.
On my development environment this function works fine.
GetWindowText(handle, Buff, nChars)
.
It returns 0 which I thought it means that no window is focused, so the focus is on the desktop. I regret not saving the source where I got the code.
The problem is on clients server, where the function returns 15, so I cannot determine whether the desktop is focused or not. Is there any function that would for sure return the same value anywhere if the desktop is focused? Thanks in advance.
EDIT: code to check the matching handles
Dim handle As IntPtr = GetForegroundWindow()
Dim shellWindows As ShellWindows = Nothing
shellWindows = New SHDocVw.ShellWindows()
For Each window As InternetExplorer In shellWindows
If window.HWND = CInt(handle) Then
Do something
End If