【发布时间】:2012-11-19 13:34:49
【问题描述】:
我正在使用 CreateProcess API 将 RealVNC 与我的 exe 集成...我只需要为创建的 vnc 客户端处理句柄,但到目前为止我没有成功。代码很简单:
procedure TForm1.VncAuth;
var
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
CmdLine: string;
title: string;
ProcHandle: THandle;
begin
FillChar(StartInfo,SizeOf(TStartupInfo),#0);
FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
StartInfo.cb := SizeOf(TStartupInfo);
CmdLine:= 'vnc.exe';
UniqueString(CmdLine);
CreateProcess(NIL ,PChar(CmdLine), NIL, NIL, False, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS
, NIL, NIL, StartInfo, ProcInfo);
ProcHandle:= ProcInfo.hProcess;
GetWindowText(ProcHandle, PChar(title), 255);
ShowMessage(title);
end;
title var 中没有返回任何内容... GetWindowText 函数只是一个测试,看看我是否有正确的句柄,如果是,我应该看到 vnc 客户端标题的权利吗? 谢谢!
【问题讨论】:
-
ProcInfo.hProcess是一个进程句柄。GetWindowText需要一个 window 句柄。它们根本不是一回事,就像门把手是刀柄一样。
标签: delphi winapi delphi-2010