知道窗口句柄,怎么得到该程序的文件名???
解决方案 »
- 如何判断字符串将在屏幕中显示所占的像素宽度
- 使用FastReport中遇到了前所未有的令人头痛的问题.
- 怎样实现版本的多语言化
- 怎么让DBLookupComboBox 默认显示 "请选择.."这样呢?
- 如何从listview中读书据?
- 我下载并安装了Delphi6.0中文版的,请问SP2可以装在中文版下吗?
- 这是不是delphi 6 中的Bug呢,只要query中有参数,就不能按正常排列,
- 请教各位高手!Installshield使用时bde中数据库别名的配置
- 如何判断出某一个目录下到底有多少文件?
- 程非编过不知难!
- 请问,我想实现按下一个TSpeedButton按钮时复制该按钮,移动鼠标时,复制的按钮随鼠标移动,放开鼠标左键后,复制的按钮停在放开的窗体位置,该
- 安装dephi 7.0后打开dephi程序提示:class tdxmemo not found
var
dwPID: DWORD;
strExePath: String;
pToolhelp: THandle;
pe: TProcessEntry32;
me: TModuleEntry32;
bOK: bool;
begin
GetWindowThreadProcessId(hWin, @dwPID);
// 建立系统快照
pToolhelp := CreateToolhelp32Snapshot(TH32CS_SNAPALL, dwPID);
// 获取可执行文件的路径
if Win32Platform <> VER_PLATFORM_WIN32_NT then // Win9x
begin
ZeroMemory(@pe, SizeOf(pe));
pe.dwSize := SizeOf(pe);
bOK := Process32First(pToolhelp, pe);
while(bOK) do
begin
if pe.th32ProcessID = dwPID then
begin
strExePath := pe.szExeFile;
break;
end;
bOK := Process32Next(pToolhelp, pe);
end;
end
else // WinNT
begin
ZeroMemory(@me, SizeOf(me));
me.dwSize := SizeOf(me);
Module32First(pToolhelp, me);
strExePath := me.szExePath;
end;
CloseHandle(pToolhelp);
Result := strExePath;
end;procedure TForm1.Button1Click(Sender: TObject);
var
hWin: THandle;
begin
// 这里替换成你要查询的窗口句柄就可以了,我随便指定了一个值。
hWin := THandle($008C0302);
ShowMessage(CrnGetExeFileFromWindow(hWin));
end;