查找窗口如何?如果文件被打开,标题栏应该有该文件的相应信息
PROCEDURE xlspd
Lpara ctitle,fname
Declare INTEGER GetDesktopWindow IN user32
Declare INTEGER GetWindow IN user32 INTEGER hwnd, INTEGER wFlag
Declare INTEGER GetWindowText IN user32;
INTEGER hwnd, STRING @lpString, INTEGER cch
Declare INTEGER GetModuleFileNameEx IN psapi;
INTEGER hProcess,;
INTEGER hModule,;
STRING ModuleName,;
INTEGER nSize
Declare INTEGER GetWindowThreadProcessId IN user32;
INTEGER
hWnd,;
INTEGER @ lpdwProcId
Declare INTEGER OpenProcess IN kernel32;
INTEGER dwDesiredAccessas,;
INTEGER bInheritHandle,;
INTEGER dwProcId
Declare INTEGER CloseHandle IN kernel32 INTEGER hObject
Declare integer GetClassName in user32;
integer hwnd, ;
string lpClassName, ;
integer nMaxCount
ctitle=lower(ctitle)
Local hDesktop, hFirstChild, hLastChild, cBuffer, nResult,hwnd,hCurrent,ii,jj,lwin(1)
hCurrent = hDesktop
ii=0
jj=1
lwin(1)=GetDesktopWindow()
hwnd=0
DO whil ii<jj
ii=II+1
hCurrent=lwin(ii)
hFirstChild = GetWindow(hCurrent, 5)
hLastChild = GetWindow(hFirstChild, 1)
hCurrent = hFirstChild
Do WHILE
hCurrent>0
cBuffer = Space(250)
nResult = GetWindowText(hCurrent, @cBuffer, Len(cBuffer))
cBuffer= SUBSTR(cBuffer, 1, nResult)
If at(ctitle,lower(cBuffer))>0
HWnd=hCurrent
ii=jj
Exit
ENDIF
jj=jj+1
LOCAL lwin(jj)
lwin(jj)=hCurrent
If hCurrent = hLastChild
Exit
Endif
hCurrent = GetWindow(hCurrent, 2)
ENDDO
ENDDO
Retu hwnd
[此贴子已经被作者于2024-5-27 12:24编辑过]