大佬教程收集整理的这篇文章主要介绍了delphi – 我可以确定一个进程ID(PID)是32位还是64位应用程序?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
IsWow64Process
功能,但使用过程句柄不是PID.
OpenProcess
功能获取pid的句柄,然后调用
IsWow64Process
功能.
请记住,您必须使用GetProcAddress
功能加载IsWow64Process
功能,因为某些版本的Windows不包括此功能.
检查此示例代码
{$APPTYPE CONSOLE} uses Windows,SysUtils; type TIsWow64Process = function(Handle:THandle; var IsWow64 : BOOL) : BOOL; stdcall; var IsWow64Process : TIsWow64Process; procedure Init_IsWow64Process; var hKernel32 : Integer; begin hKernel32 := LoadLibrary(kernel32); if (hKernel32 = 0) then RaiseLastOSError; try IsWow64Process := GetProcAddress(hkernel32,'IsWow64Process'); finally FREELIbrary(hKernel32); end; end; function PidIs64BitsProcess(dwProcessId: DWORD): @R_489_8487@an; var IsWow64 : BOOL; PidHandle : THandle; begin Result := false; if Assigned(IsWow64Process) then begin //check if the current app is running under WOW if IsWow64Process(GetCurrentProcess(),IsWow64) then Result := IsWow64 else RaiseLastOSError; //the current delphi App is not running under wow64,so the current Window OS is 32 bit //and obviously all the apps are 32 bits. if not Result then Exit; PidHandle := OpenProcess(PROCESS_QUERY_INFORMATION,false,dwProcessId); if PidHandle > 0 then try if (IsWow64Process(PidHandle,IsWow64)) then Result := not IsWow64 else RaiseLastOSError; finally CloseHandle(PidHandlE); end; end; end; begin try Init_IsWow64Process; //here pass the pid which you want to check Writeln(BoolToStr(PidIs64BitsProcess(1940),TruE)); except on E:Exception do Writeln(E.Classname,': ',E.messagE); end; Readln; end.
以上是大佬教程为你收集整理的delphi – 我可以确定一个进程ID(PID)是32位还是64位应用程序?全部内容,希望文章能够帮你解决delphi – 我可以确定一个进程ID(PID)是32位还是64位应用程序?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。