Нашел на просторах интернета (https://thesiebelscholar.blogspot.com/) пример скрипта по получению PID и Thread Id
По сути решение довольно простое, единственный недостаток это невозможность использовать его в высоконагруженных системах, т.к. оно будет создавать нагрузку на диск.
function SetThreadPID() { var pid = TheApplication().GetProfileAttr("XXX OS PID"); var threadId = TheApplication().GetProfileAttr("PPT OS Thread ID"); var line, pidThread, path, command, outs; try { if (threadId == "") { if (TheApplication().GetProfileAttr("IsStandaloneWebClient") == "TRUE") { path = gsLogPath; } else { path = TheApplication().GetProfileAttr("Syspref Error Trace Temp Loc"); } if (path != "" && path.toUpperCase() != "FALSE") { var unique = TheApplication().LoginName()+"-"+TimeStamp("DateTimeMilli"); TheApplication().TraceOn(path+"Trace-"+unique+"_$p_$t.log", "Allocation", "All"); TheApplication().Trace("TEST"); TheApplication().TraceOff(); command = "dir "+path+"Trace-"+unique+"_*.log > "+path+"Trace-"+unique+".log"; outs = Clib.system(command); var fp:File = Clib.fopen(path+"Trace-"+unique+".log","r"); if (fp != null){ while(Clib.feof(fp) == 0){ line = Clib.fgets(fp); if (line.length > 0){ if (line.indexOf(unique)>=0) { pidThread = line.substring(line.indexOf(unique)+unique.length+1, line.length - 5) pid = pidThread.substring(0, pidThread.indexOf("_")); threadId = pidThread.substring(pidThread.indexOf("_")+1); TheApplication().SetProfileAttr("PPT OS PID", pid); TheApplication().SetProfileAttr("PPT OS Thread ID", threadId); Clib.fclose(fp); outs = Clib.remove(path+"Trace-"+unique+"_"+pid+"_"+threadId+".log") outs = Clib.remove(path+"Trace-"+unique+".log") break; } } } } } } } catch(e) { RaiseError(e); } finally { fp = null; } }
Я использую что-то такое для windows:
ОтветитьУдалитьvar tId = "Thread Id = " + eval('SElib.dynamicLink("kernel32.dll", "GetCurrentThreadId", STDCALL)')
var procId = "O/S Proc Id = " + eval('SElib.dynamicLink("kernel32.dll", "GetCurrentProcessId", STDCALL)')