下面这段代码是查找当前系统运行的所有窗口名称的。窗口名称保存在MyStringList里。
Function My_RefreshForm(MyStringList:TStringList):Boolean;
var
hCurrentWindow: HWnd;
szText: array[0..254] of char;
begin
MyStringList.Clear;
hCurrentWindow := GetWindow(application.Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
MyStringList.Add(StrPas(@szText));
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
Result:=true;
end;现在的问题是,如果这个函数写在EXE文件里调用,没问题,但是如果写在DLL里调用,那么
返回空值。
调试中发现问题出在这一句代码:
hCurrentWindow := GetWindow(application.Handle, GW_HWNDFIRST);
在DLL中调用时,application.Handle也有值,但是返回值hCurrentWindow 为0。
请问产生问题的原因是什么,如何解决?
Function My_RefreshForm(MyStringList:TStringList):Boolean;
var
hCurrentWindow: HWnd;
szText: array[0..254] of char;
begin
MyStringList.Clear;
hCurrentWindow := GetWindow(application.Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255) > 0 then
MyStringList.Add(StrPas(@szText));
hCurrentWindow := GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
Result:=true;
end;现在的问题是,如果这个函数写在EXE文件里调用,没问题,但是如果写在DLL里调用,那么
返回空值。
调试中发现问题出在这一句代码:
hCurrentWindow := GetWindow(application.Handle, GW_HWNDFIRST);
在DLL中调用时,application.Handle也有值,但是返回值hCurrentWindow 为0。
请问产生问题的原因是什么,如何解决?
解决方案 »
- 放分...
- 请教Delphi7编写的程序升级到Delphi2007
- 请问个delphi编写的记事本的一个问题
- 请问VC中的new HANDLE转换到Delphi中该如何写呢?
- 耶,怪了...
- 有关VclSkin的问题,如何在窗体更新时,背景为不透明。因为刷新窗体时,出现很多的闪动,反正很乱。请大家帮忙。
- 将没有太多时间上网,散分,“对不起”
- 各位高手,请教一个关于网络数据传递的问题
- 自学SQL起,我一直被这个问题所困扰,我看了好多医生,都没有用。看来我死定了。
- 用WinSock控件进行二进制文件传输问题
- 在线等待(100分-前20人有分)--请装dephi6.0的朋友帮个忙<一个E-mail的例子>
- 100分寻找 将DELPHI写的程序转换为繁体版的方案!!!
to aiirii(aiirii)
请问如何传APPLICATION.HANDLE。是在DLL的入口吗?
请看这两句代码:
1
hCurrentWindow := GetWindow(application.Handle, GW_HWNDFIRST);
2
hCurrentWindow := GetWindow(getactivewindow, GW_HWNDFIRST);1只在EXE里调用有效,2只在DLL里调用有效,请问原因
但是我想问问这个原因