سلام
ببین از این سورس و کد ها چیزی پیدا میکنی یا نه؟
درمورد session id هست
لینک 1
کد1:
procedure TIWServerController.IWServerControllerBaseNewSessi on (ASession: TIWApplication; var VMainForm: TIWBaseForm);
var
i: integer;
List: TList;
App: TIWApplication;
begin
List:=GSessions.LockList;
try
for i:=0 to List.Count - 1 do begin
App:=TIWApplication(List[i]);
if App <> ASession then begin
GSessions.Remove(App);
App.Free;
end;
end;
finally
GSessions.UnLockList;
end;
ASession.Data:=TIWUserSession.Create(nil);
end;
کد2:
function ProcessIdToSessionId(dwProcessId: DWORD; pSessionId: DWORD): BOOL; stdcall; external 'kernel32.dll';
function GetSessionIdfromProccessId(const processId: DWORD; var sessionId: DWORD): boolean;
begin
result:=ProcessIdToSessionId(processId, DWORD(@sessionId));
end;
function GetCurrentSessionId: DWORD;
begin
if not GetSessionIdfromProccessId(GetCurrentProcessId,res ult) then
result:=0;
end;
کد3:
function ProcessIdToSessionId(dwProcessId: DWORD; pSessionId: DWORD): BOOL; stdcall; external 'kernel32.dll';
function GetSessionIdfromProccessId(const processId: DWORD; var sessionId: DWORD): boolean;
begin
result:=ProcessIdToSessionId(processId, DWORD(@sessionId));
end;
function GetCurrentSessionId: DWORD;
begin
if not GetSessionIdfromProccessId(GetCurrentProcessId,res ult) then
result:=0;
end;
procedure terminateSameSessionId;
var
bContinue: BOOL;
Ret: BOOL;
Ph: THandle;
sh: THandle;
pe: TProcessEntry32;
n: string;
myProcessId: Dword;
mySessionId: DWORD;
sessionId: DWORD;
begin
mySessionId:=GetCurrentSessionId;
sh:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe.dwSize:=SizeOf(pe);
bContinue:=Process32First(sh, pe);
n:=WideLowerCase(ExtractFileName(Application.ExeNa me));
GetWindowThreadProcessID(Application.Handle, @myProcessId);
while Integer(bContinue) <> 0 do begin
if WideLowerCase(pe.szExeFile) = copy(n,1,length(pe.szExeFile)) then
if pe.th32ProcessID <> myProcessId then
if GetSessionIdfromProccessId(pe.th32ProcessID,sessio nId) then
if sessionId=mySessionId then begin
Ph:=OpenProcess(1, BOOL(0), pe.th32ProcessID);
Ret:=TerminateProcess(Ph, 0);
end;
bContinue:=Process32Next(sh, pe);
end;
CloseHandle(sh);
end; //terminate same session id
امیدوارم کمکت کنه
موفق باشی