这个就好办了.给你几个函数可以控制任意用户的执行数量<br><br>function GetUserAndDomainFromPID(ProcessId: DWORD; var User: string): Boolean; {获取进程的用户名函数}<br>var<br> hToken: THandle;<br> cbBuf: Cardinal;<br> ptiUser: PSIDAndAttributes;<br> snu: SID_NAME_USE;<br> ProcessHandle: THandle;<br> UserSize, DomainSize: DWORD;<br> bSuccess: Boolean;<br> Domain: string;<br>begin<br> Result := False;<br> ProcessHandle := OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId);<br> if ProcessHandle <> 0 then<br> begin<br> if OpenProcessToken(ProcessHandle, TOKEN_QUERY, hToken) then<br> begin<br> bSuccess := GetTokenInformation(hToken, TokenUser, nil, 0, cbBuf);<br> ptiUser := nil;<br> while (not bSuccess) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) do<br> begin<br> ReallocMem(ptiUser, cbBuf);<br> bSuccess := GetTokenInformation(hToken, TokenUser, ptiUser, cbBuf, cbBuf);<br> end;<br> CloseHandle(hToken);<br><br> if not bSuccess then Exit;<br> UserSize := 0;<br> DomainSize := 0;<br> LookupAccountSid(nil, ptiUser.Sid, nil, UserSize, nil, DomainSize, snu);<br> if (UserSize <> 0) and (DomainSize <> 0) then<br> begin<br> SetLength(User, UserSize);<br> SetLength(Domain, DomainSize);<br> if LookupAccountSid(nil, ptiUser.Sid, PChar(User), UserSize,<br> PChar(Domain), DomainSize, snu) then<br> begin<br> Result := True;<br> User := StrPas(PChar(User));<br> end;<br> end;<br> FreeMem(ptiUser);<br> end;<br> CloseHandle(ProcessHandle);<br> end;<br>end;<br><br>function GetUserName:String; {获取当前登陆用户名函数}<br>var<br> pcUser
Char;<br> dwUSize
WORD;<br>begin<br> dwUSize:=40; //用户名长度不大于20个字符<br> Result:='';<br> GetMem(pcUser,dwUSize);<br> try<br> if Windows.GetUserName(pcUser,dwUSize) then<br> Result:=pcUser<br> finally<br> FreeMem(pcUser);<br> end;<br>end;<br><br>function CheckAppNum(Username:String):Integer; {检测当前用户程序运行数量函数}<br>var<br> ProcessListHandle: THandle;<br> ProcessStruct: TProcessEntry32;<br> ContinueLoop:bool;<br> users,dom:string;<br> Num:integer;<br>begin<br>Num:=0;<br>users:='';<br>ProcessListHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br>ProcessStruct.dwSize:=Sizeof(ProcessStruct);<br>ContinueLoop:=Process32First(ProcessListHandle,ProcessStruct);<br>while ContinueLoop do<br>begin<br>GetUserAndDomainFromPID(ProcessStruct.th32ProcessID,users);<br>if users=Username then Num:=Num+1;<br>ContinueLoop:=Process32Next(ProcessListHandle,ProcessStruct);<br>end;<br>Result:=Num;<br>end;<br>通过以上函数就可以知道任意用户名的当前运行进程,就可以控制他运行的程序数量了,以上的绝对可以用.给分吧.