Page 1 of 1

Process( ).Handles empty in Vista 64-bit

Posted: Sat Jun 21, 2008 12:22 pm
by brian
It seems this doesn't work at all Vista-64 bit, process handles are empty, itemcount 0.

Posted: Thu Jul 03, 2008 9:21 pm
by madshi
Sorry for the late reply.

The Windows API used for enumerating handles doesn't work when being called from within a 32bit process in a 64bit OS, sadly. You'd need a 64bit process to get this information. Shame on Microsoft... :cry:

Posted: Sat Jul 05, 2008 3:58 am
by brian
Ahh I see. Shame on borland/cg for not having a 64-bit compiler yet.

Posted: Sun May 16, 2010 7:51 am
by brian
After further testing, this seems to be working in Windows 7-64 bit, but only if both processes are running with the same user privileges. For example, you run your delphi app normally, and try to get the handles for another (32-bit) app that you ran as admin, it won't work. If both are are under normal privs or both as admin, it works. Think of any workaround for this?

example code


Var a: integer;
b: string;
begin

with Process('whatever.exe').Handles do
for a := 0 to ItemCount - 1 do
with Items[a] do
begin
Application.ProcessMessages;
if not IsValid then Continue;
if not (ObjType in [otFile, otFileMapping]) then Continue;
b := KernelObj.ObjName;
if b = '' then Continue;
memo1.lines.add(b);
end;

Posted: Tue May 18, 2010 8:25 am
by madshi
I'm surprised that it works at all, but I won't complain about that... :wink:

I guess the "proper" solution to the privileges problem is to either install your app as a service, or to add a manifest to your exe file which tells Windows that you need admin rights.

Posted: Tue May 18, 2010 8:28 am
by brian
Well, the thing is, if your app is running as admin, and the other app isn't, it still doesn't work, both have to be running on the same level :O

Posted: Tue May 18, 2010 8:45 am
by madshi
That sounds very weird to me. Honestly, I have no idea why it behaves this way! Maybe MS has hardcoded the underlying APIs to work this way? Don't really know... :?

Re: Process( ).Handles empty in Vista 64-bit

Posted: Wed Dec 22, 2010 12:50 am
by Sugar70
You'd need a 64bit process to get this information. Shame on Microsoft... : :crazy: :crazy:

Re: Process( ).Handles empty in Vista 64-bit

Posted: Wed Dec 22, 2010 1:56 am
by brian
It does actually work with a 32-bit process, if both your application and the one retrieving the info about, are running on the same privilege level (user/user or admin/admin).