<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=3412241</guid>
        <pubDate>Sun, 09 Feb 2014 19:08:21 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=3412241</link>
        <description><![CDATA[Fr0sT: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=3411983'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Виталь &#064; <time class="tag-quote__quoted-time" datetime="2014-02-08T20:15:57+04:00">08.02.14, 16:15</time></span><div class='quote '>QueryFullProcessImageName</div></div><br>
Minimum supported client	Windows Vista [desktop apps only]<br>
Minimum supported server	Windows Server 2008 [desktop apps only]<br>
Header	WinBase.h (include Windows.h)<br>
Library	Kernel32.lib<br>
DLL	Kernel32.dll]]></description>
        <author>Fr0sT</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=3411983</guid>
        <pubDate>Sat, 08 Feb 2014 16:15:57 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=3411983</link>
        <description><![CDATA[Виталь: Пожалуй, апну тему.<br>
Использую приведенный выше код.<br>
GetModuleFileNameExA на некоторых компьютерах возвращает ошибку,<br>
Getlasterror = 299, запрос Readprocessmemory или writeprocessmemory выполнен только частично.<br>
Оно же &quot;Only part of a ReadProcessMemory or WriteProcessMemory request was completed.&quot; или ERROR_PARTIAL_COPY.<br>
Пробовал увеличить буффер - дело не в этом. GetModuleFileNameExW дает ровно тот же результат - либо обе работают, либо обе нет.<br>
<br>
Работает на WindowsXP x86, Windows2003 x86, Windows 2003 x64.<br>
Не работает: словил только на Win2003x64, запущенном под Oracle VirtualBox, но есть и другие эпизоды.<br>
<br>
Сделал мощный дебаг, в Memo выводится все и на каждом шаге. Функции GetModuleFileNameEx передается нормальный хендл.<br>
Приложение 32битное, в диспетчере задач отмечено как *32. Возможно, как-то связано. Запуск в режиме совместимости с любой другой ОС во первых, не решает задачу, во вторых - выдается тот же результат. Запустившее приложение еще в памяти, не тот случай когда бы оно успело закрыться. <strong class='tag-b'>Как фиксить?</strong><br>
<br>
---<br>
еще порылся и выяснил, что ошибка возникает только при запуске приложения из проводника (Explorer.exe) либо через CMD.exe на некоторых 64-битных системах. Запуск другой программой определяется.<br>
Решается использованием GetProcessImageFileNameA, которая дает путь в виде &#092;Device1&#092;PArtition2&#092;windows&#092;explorer.exe или типа того, но сойдет.<br>
Надеюсь, GetProcessImageFileNameA есть на всех системах и не будет &quot;точка входа не найдена&quot;... Рекомендуемую QueryFullProcessImageName в системных библиотеках не нашел, в модулях Delphi тем более.]]></description>
        <author>Виталь</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217830</guid>
        <pubDate>Sat, 14 Mar 2009 00:11:26 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217830</link>
        <description><![CDATA[akkorn: Демо<br>Александр<br><br>А КТО ЕСТЬ ТАКОЙ огромный спец, кто мог бы это провернуть???<br>Пасиб))]]></description>
        <author>akkorn</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217828</guid>
        <pubDate>Sat, 14 Mar 2009 00:00:33 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217828</link>
        <description><![CDATA[Демо: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=2217430'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>akkorn &#064; <time class="tag-quote__quoted-time" datetime="2009-03-13T14:08:53+00:00">13.03.09, 14:08</time></span><div class='quote '>В том то и проблема, у меня не выходит (если честно, то я не спец в программировании, тока VB изучаю, а тут совсем др. язык).. Помогите, плиз, если можете)<br>
Спасибо.</div></div><br>
<br>
Ты думаешь Розыч спец в VB?<br>
ЛУчше задать вопрос в соответствующем разделе форума.]]></description>
        <author>Демо</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217430</guid>
        <pubDate>Fri, 13 Mar 2009 14:08:53 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217430</link>
        <description><![CDATA[akkorn: Rouse<br>Александр<br><br>В том то и проблема, у меня не выходит (если честно, то я не спец в программировании, тока VB изучаю, а тут совсем др. язык).. Помогите, плиз, если можете)<br>Спасибо.]]></description>
        <author>akkorn</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217416</guid>
        <pubDate>Fri, 13 Mar 2009 13:55:30 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217416</link>
        <description><![CDATA[Rouse_: Точно так-же, берешь приведенный код и переписываешь его на VB.]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217406</guid>
        <pubDate>Fri, 13 Mar 2009 13:42:37 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=2217406</link>
        <description><![CDATA[akkorn: Уважаемые&#33;&#33;&#33; ПОМОГИТЕ&#33;&#33;&#33;&#33;  :huh: <br>Ни кто не пособит- как туже самую задачу воспроизвести на Visual Basic 6.0 ???<br><br>т.е. меня интересует, КАК узнать имя процесса запустившего мою программу, но через VB?<br><br>СПАСИБО огромное любому, кто хоть что то посоветует  ;)  &#33; )))))]]></description>
        <author>akkorn</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758629</guid>
        <pubDate>Fri, 09 Nov 2007 14:05:55 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758629</link>
        <description><![CDATA[Riply: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1758044'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rennigth &#064; <time class="tag-quote__quoted-time" datetime="2007-11-09T09:32:56+00:00">09.11.07, 09:32</time></span><div class='quote '>Вроде без особых косяков...</div></div><br>
Да. На первый взгляд, не видно :)<br>
<br>
P.S.<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1758044'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rennigth &#064; <time class="tag-quote__quoted-time" datetime="2007-11-09T09:32:56+00:00">09.11.07, 09:32</time></span><div class='quote '>Желание дамы - закон&#33; </div></div><br>
Вот бы везде было так, как на форумах по программированию :)]]></description>
        <author>Riply</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758182</guid>
        <pubDate>Fri, 09 Nov 2007 11:02:52 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758182</link>
        <description><![CDATA[Rouse_: В действительности срабатывает он намного чаще 10 мс. Иначе пропала бы возможность работы с мультимедийными таймерами :)]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758175</guid>
        <pubDate>Fri, 09 Nov 2007 10:58:46 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758175</link>
        <description><![CDATA[Rose: Ясно, спасибо. Правда насколько я знаю, системный таймер на NT тикает каждые 10 мс (тогда же планировщик потоков получает управление), так что соблюсти документированную дискретность 100 нс никак не получится. Или это я с прямым углом перепутал?]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758162</guid>
        <pubDate>Fri, 09 Nov 2007 10:50:40 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758162</link>
        <description><![CDATA[Rouse_: Она вызывается из KeUpdateSystemTime который дергается каждый раз при срабатывании прерывания системного таймера (тамже увеличивается и знаение возвращаемое GetTiCkCount и много чего еще) :)]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758150</guid>
        <pubDate>Fri, 09 Nov 2007 10:42:32 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758150</link>
        <description><![CDATA[Rose: Ага, осталось только выяснить где и когда вызывается KeUpdateRunTime? Надо полагать, по прерыванию от таймера?]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758147</guid>
        <pubDate>Fri, 09 Nov 2007 10:38:04 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758147</link>
        <description><![CDATA[Rouse_: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1758128'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rose &#064; <time class="tag-quote__quoted-time" datetime="2007-11-09T10:25:05+00:00">09.11.07, 10:25</time></span><div class='quote '>На многопроцессорной UserTime + KernelTime уже может и превышать</div></div><br>
Истину глаголишь  :yes: <br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1758128'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rose &#064; <time class="tag-quote__quoted-time" datetime="2007-11-09T10:25:05+00:00">09.11.07, 10:25</time></span><div class='quote '>Кстати, мне тоже интересно, как система следит за тем, в каком режиме (user или kernel) выолняется поток? </div></div><br>
Вычисляется в KeUpdateRunTime()<br>
<br>
Грубо говоря выглядит примерно так:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;push &nbsp; &nbsp;ebx &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; we will destroy ebx</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;inc &nbsp; &nbsp; dword ptr [eax]+PcPrcbData+PbInterruptCount</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;mov &nbsp; &nbsp; ebx, [eax]+PcPrcbData+PbCurrentThread ; (ebx)-&#62;current thread</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;mov &nbsp; &nbsp; ecx, ThApcState+AsProcess[ebx]</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; (ecx)-&#62;current thread&#39;s process</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;test &nbsp; &nbsp;dword ptr [ebp]+TsEFlags,EFLAGS_V86_MASK</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;jne &nbsp; &nbsp; Kutp20 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; if ne, user mode</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;test &nbsp; &nbsp;byte ptr [ebp]+TsSegCs, MODE_MASK ; test if prev mode was kernel</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;jne &nbsp; &nbsp; Kutp20 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; if ne, user mode</div><div class="code_line">&nbsp;</div><div class="code_line">;</div><div class="code_line">; Update the total time spent in kernel mode</div><div class="code_line">;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;mov &nbsp; &nbsp; edx, 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; set kernel mode</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;inc &nbsp; &nbsp; dword ptr [eax].PcPrcbData.PbKernelTime</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;cmp &nbsp; &nbsp; byte ptr [esp+8], DISPATCH_LEVEL</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;jc &nbsp; &nbsp; &nbsp;short Kutp4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; OldIrql&#60;2, then kernel</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ja &nbsp; &nbsp; &nbsp;short Kutp3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; OldIrql&#62;2, then interrupt</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758128</guid>
        <pubDate>Fri, 09 Nov 2007 10:25:05 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758128</link>
        <description><![CDATA[Rose: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Конечно, но т.к. система псевдомногопоточная, т.е. в единый квант времени выполняется только что-то одно, то ExitTime - CreationTime никогда не будет меньше чем UserTime + KernelTime</div></div><br>
<br>
Логично, но это верно только для однопроцессорной системы. На многопроцессорной UserTime + KernelTime уже может и превышать  ;) <br>
<br>
Кстати, мне тоже интересно, как система следит за тем, в каком режиме (user или kernel) выолняется поток?]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758125</guid>
        <pubDate>Fri, 09 Nov 2007 10:20:57 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758125</link>
        <description><![CDATA[Rouse_: <strong class='tag-b'>Rose</strong>, ну это то понятно :) Простой не учитывался ж никогда :)))<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1758114'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rose &#064; <time class="tag-quote__quoted-time" datetime="2007-11-09T10:12:20+00:00">09.11.07, 10:12</time></span><div class='quote '>так как вроде бы UserTime и KernelTime суммируются по всем потокам процесса. </div></div><br>
Конечно, но т.к. система псевдомногопоточная, т.е. в единый квант времени выполняется только что-то одно, то ExitTime - CreationTime никогда не будет меньше чем UserTime + KernelTime :)]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758114</guid>
        <pubDate>Fri, 09 Nov 2007 10:12:20 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758114</link>
        <description><![CDATA[Rose: <strong class='tag-b'>Rouse_</strong><br>
<br>
Кстати, ExitTime - CreationTime не равно UserTime + KernelTime. Когда все потоки процесса простаивают, UserTime и KernelTime не меняется. В этом случае UserTime + KernelTime будет меньше. И наоборот, если у процесса несколько потоков и все они работают безперебойно, UserTime + KernelTime может быть больше чем ExitTime - CreationTime, так как вроде бы UserTime и KernelTime суммируются по всем потокам процесса.]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758112</guid>
        <pubDate>Fri, 09 Nov 2007 10:10:38 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758112</link>
        <description><![CDATA[Rennigth: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
Что значит чем отличаются. UserTime + KernelTime = общее время работы процесса. <br>
</div></div><br>
Логично... :) Я если в двух словах, как высчитываеютя UserTime и KernelTime? Просто плохо себе представляю как система может их различать :( <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-09T10:12:00+00:00">09.11.07, 10:12</time></span></span><br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
Соответственно время создания процесса, время, которое его потоки выполнялись в пользовательском режиме и режиме ядра. Здесь описано:<br>
http://msdn2.microsoft.com/en-us/library/ms683223.aspx <br>
</div></div><br>
О спс, почитаем...]]></description>
        <author>Rennigth</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758108</guid>
        <pubDate>Fri, 09 Nov 2007 10:07:25 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758108</link>
        <description><![CDATA[Rose: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Кстати вопросик, чем отличаеютя в структуре SYSTEM_PROCESS_INFORMATION времена CreateTime, UserTime, KernelTime?</div></div><br>
Соответственно время создания процесса, время, которое его потоки выполнялись в пользовательском режиме и режиме ядра. Здесь описано:<br>
http://msdn2.microsoft.com/en-us/library/ms683223.aspx]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758106</guid>
        <pubDate>Fri, 09 Nov 2007 10:04:19 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758106</link>
        <description><![CDATA[Rouse_: Что значит чем отличаются. UserTime + KernelTime = общее время работы процесса.]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758044</guid>
        <pubDate>Fri, 09 Nov 2007 09:32:56 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1758044</link>
        <description><![CDATA[Rennigth: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
Я хотела сказать, что у нас нет уверенности в том, что ID, с которым мы работаем,<br>
действительно ID нашего родителя, а не какого-то левого процесса.<br>
(случай с использованием старого значения ID, для нового процесса).<br>
Соответственно, как положительный ответ OwnerProcessIs_IExplore, так и отрицательный<br>
верны с некой долей вероятности.<br>
Проверять можно так: сравнить время нашего создания, с временем создания &quot;родителя&quot;.<br>
И если родитель был создан позже нас, то кричать о подлоге  <br>
</div></div><br>
<br>
Желание дамы - закон&#33; :) Вроде без особых косяков...<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">uses ShlObj //Лень в ручную экспортировать</div><div class="code_line">//...</div><div class="code_line">&nbsp;</div><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp;SYSTEM_PROCESSES_AND_THREADS_INFORMATION = 5;</div><div class="code_line">&nbsp;&nbsp;NT_STATUS_SUCCESS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= DWord({text}000000);</div><div class="code_line">&nbsp;&nbsp;NT_STATUS_ACCESS_DENIED &nbsp; &nbsp; &nbsp; &nbsp;= DWord($C0000022);</div><div class="code_line">&nbsp;&nbsp;NT_STATUS_INFO_LENGTH_MISMATCH = DWord($C0000004);</div><div class="code_line">&nbsp;&nbsp;CSIDL_PROGRAM_FILES = {text}26;</div><div class="code_line">&nbsp;&nbsp;IExplorePath: string = &#39;\Internet Explorer\IEXPLORE.EXE&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp;PSYSTEM_THREAD_INFORMATION = ^_SYSTEM_THREAD_INFORMATION;</div><div class="code_line">&nbsp;&nbsp;_SYSTEM_THREAD_INFORMATION &nbsp;= packed record</div><div class="code_line">&nbsp;&nbsp; &nbsp;KernelTime: LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;UserTime: LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;CreateTime: LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WaitTime: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;StartAddress: Pointer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;UniqueProcess: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;UniqueThread: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Priority: Integer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;BasePriority: Integer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ContextSwitchCount: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;State: Longint;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WaitReason: Longint;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;PSYSTEM_PROCESS_INFORMATION = ^_SYSTEM_PROCESS_INFORMATION;</div><div class="code_line">&nbsp;&nbsp;_SYSTEM_PROCESS_INFORMATION = packed record</div><div class="code_line">&nbsp;&nbsp; &nbsp;NextOffset: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ThreadCount: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Reserved1: array [0..5] of ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;CreateTime: FILETIME;</div><div class="code_line">&nbsp;&nbsp; &nbsp;UserTime: FILETIME;</div><div class="code_line">&nbsp;&nbsp; &nbsp;KernelTime: FILETIME;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ModuleNameLength: WORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ModuleNameMaxLength: WORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ModuleName: PWideChar;</div><div class="code_line">&nbsp;&nbsp; &nbsp;BasePriority: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ProcessID: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;InheritedFromUniqueProcessID: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;HandleCount: ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;Reserved2 : array[0..1] of ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PeakVirtualSize : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;VirtualSize : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PageFaultCount : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PeakWorkingSetSize : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WorkingSetSize : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;QuotaPeakPagedPoolUsage : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;QuotaPagedPoolUsage : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;QuotaPeakNonPagedPoolUsage : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;QuotaNonPagedPoolUsage : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PageFileUsage : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PeakPageFileUsage : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PrivatePageCount : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ReadOperationCount : LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WriteOperationCount : LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;OtherOperationCount : LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ReadTransferCount : LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;WriteTransferCount : LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;OtherTransferCount : LARGE_INTEGER;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ThreadInfo: array [0..0] of _SYSTEM_THREAD_INFORMATION;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;</div><div class="code_line">function ZwQuerySystemInformation(ASystemInformationClass: Cardinal;</div><div class="code_line">&nbsp;&nbsp;ASystemInformation: Pointer; ASystemInformationLength: Cardinal;</div><div class="code_line">&nbsp;&nbsp;AReturnLength: PCardinal): Cardinal; stdcall; external &#39;ntdll.dll&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">function GetModuleFileNameExA(hProcess: THandle; hModule: HModule;</div><div class="code_line">&nbsp;&nbsp;lpFilename: PAnsiChar; nSize: DWORD): DWORD; stdcall; external &#39;PSAPI.dll&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">function OwnerProcessIs_IExplore: Boolean;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;pSI, pSITemp: PSYSTEM_PROCESS_INFORMATION;</div><div class="code_line">&nbsp;&nbsp;hParentProcess: THandle;</div><div class="code_line">&nbsp;&nbsp;dwParentProcessID, dwSelfProcessID: DWORD;</div><div class="code_line">&nbsp;&nbsp;lpFileName, lpPFPath: PAnsiChar;</div><div class="code_line">&nbsp;&nbsp;dwOffSet, dwSize: DWORD;</div><div class="code_line">&nbsp;&nbsp;ftSelfProcTime: FILETIME;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;Result := False;</div><div class="code_line">&nbsp;&nbsp;dwSelfProcessID := GetCurrentProcessId;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;dwSize := 0;</div><div class="code_line">&nbsp;&nbsp;dwParentProcessID := 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;if ZwQuerySystemInformation(SYSTEM_PROCESSES_AND_THREADS_INFORMATION,</div><div class="code_line">&nbsp;&nbsp; &nbsp;nil, 0, @dwSize) &#60;&#62; NT_STATUS_INFO_LENGTH_MISMATCH then Exit;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;pSI := VirtualAlloc(nil, dwSize, MEM_COMMIT or MEM_RESERVE, PAGE_READWRITE);</div><div class="code_line">&nbsp;&nbsp;if Assigned(pSI) then</div><div class="code_line">&nbsp;&nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp;if ZwQuerySystemInformation(SYSTEM_PROCESSES_AND_THREADS_INFORMATION,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;pSI, dwSize, @dwSize) = NT_STATUS_SUCCESS then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;pSITemp := pSI;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;repeat</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if pSITemp^.ProcessID = dwSelfProcessID then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwParentProcessID := pSITemp^.InheritedFromUniqueProcessID;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ftSelfProcTime := pSITemp^.CreateTime;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dwOffSet := pSITemp^.NextOffset;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pSITemp := Pointer(DWORD(pSITemp) + dwOffSet);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;until dwOffSet = 0;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if dwParentProcessID &#62; 0 then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;pSITemp := pSI;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;repeat</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if pSITemp^.ProcessID = dwParentProcessID then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if CompareFileTime(ftSelfProcTime, pSITemp^.CreateTime) &#62; 0 then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hParentProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; False, dwParentProcessID);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if hParentProcess &#62; 0 then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpFileName := GetMemory(MAX_PATH);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ZeroMemory(lpFileName, MAX_PATH);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpPFPath := GetMemory(MAX_PATH);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ZeroMemory(lpPFPath, MAX_PATH);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if SHGetSpecialFolderPath(0, lpPFPath, CSIDL_PROGRAM_FILES, False) and</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(GetModuleFileNameExA(hParentProcess, 0, lpFileName, MAX_PATH) &#62; 0) then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result := lpPFPath + IExplorePath = lpFileName;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;finally</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FreeMemory(lpPFPath);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;finally</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FreeMemory(lpFileName);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;finally</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CloseHandle(hParentProcess);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dwOffSet := pSITemp^.NextOffset;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pSITemp := Pointer(DWORD(pSITemp) + dwOffSet);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;until dwOffSet = 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp;finally</div><div class="code_line">&nbsp;&nbsp; &nbsp;VirtualFree(pSI, 0, MEM_RELEASE);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">end;</div></ol></div></div></div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-09T09:36:28+00:00">09.11.07, 09:36</time></span></span><br>
Кстати вопросик, чем отличаеютя в структуре SYSTEM_PROCESS_INFORMATION времена CreateTime, UserTime, KernelTime?]]></description>
        <author>Rennigth</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1757798</guid>
        <pubDate>Fri, 09 Nov 2007 08:21:16 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1757798</link>
        <description><![CDATA[Riply: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1757753'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rennigth &#064; <time class="tag-quote__quoted-time" datetime="2007-11-09T08:01:33+00:00">09.11.07, 08:01</time></span><div class='quote '>Riply, поясни плиз. Не понял что ты имеешь ввиду под &quot;настоящим родителем&quot;. </div></div><br>
<br>
Я хотела сказать, что у нас нет уверенности в том, что ID, с которым мы работаем,<br>
действительно ID нашего родителя, а не какого-то левого процесса.<br>
(случай с использованием старого значения ID, для нового процесса).<br>
Соответственно, как положительный ответ OwnerProcessIs_IExplore, так и отрицательный<br>
верны с некой долей вероятности.<br>
Проверять можно так: сравнить время нашего создания, с временем создания &quot;родителя&quot;.<br>
И если родитель был создан позже нас, то кричать о подлоге :)]]></description>
        <author>Riply</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1757753</guid>
        <pubDate>Fri, 09 Nov 2007 08:01:33 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1757753</link>
        <description><![CDATA[Rennigth: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
Ну раз уж выкладывается решение для copy/paste`ого использования, то не плохо<br>
было бы включить в него и проверку настоящего родителя мы нашли или так &quot;погулять вышедшего&quot;<br>
</div></div><br>
Riply, поясни плиз. Не понял что ты имеешь ввиду под &quot;настоящим родителем&quot;. <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-09T08:07:58+00:00">09.11.07, 08:07</time></span></span><br>
Это:<br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
P.S.<br>
Только проку от данной методики, как от козла молока.<br>
Процесса родителя уже может и не быть в помине, пока мы тут соизволяем его искать <br>
И полученный нами ID, можно выбрасывать на помойку.<br>
<br>
Гораздо лучше использовать NtQuerySystemInformation с <br>
параметром SystemProcessesAndThreadsInformation - можно обойтись одним &quot;снимком&quot;.<br>
Правда и с CreateToolhelp32Snapshot можно, но придется запоминать ProcEntry`ы. <br>
<br>
P.S.S.<br>
&gt;Да нет с TlHelp32 работал<br>
&gt;Я люблю, когда появляються задачи по программированию.. <br>
&gt;Но тут немного в невиддении насчет родителя.. <br>
Ой как &quot;не вяжутся&quot; эти три фразы  <br>
(особенно учитывая, что в Help`е есть пример <br>
<br>
Забыла еще одну неприятную вещь:<br>
Может получиться так, что к моменту нашего поиска, родитель уже умрет,<br>
и будет создан другой процесс с такм же ID, как и у родителя.<br>
А вот чтобы не попасть впросак с этим, придется использовать NtQuerySystemInformation<br>
и сравнивать времена создания найденого нами родителя и наше. <br>
</div></div><br>
имеешь ввиду? Или более жесткая проверка на то что это именно IE?]]></description>
        <author>Rennigth</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1757375</guid>
        <pubDate>Thu, 08 Nov 2007 20:15:56 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1757375</link>
        <description><![CDATA[Riply: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1756540'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rennigth &#064; <time class="tag-quote__quoted-time" datetime="2007-11-08T09:35:55+00:00">08.11.07, 09:35</time></span><div class='quote '>Вобщем если я правильно понял автору нужно что-то врое этого:</div></div><br>
<br>
Ну раз уж выкладывается решение для copy/paste`ого использования, то не плохо<br>
было бы включить в него и проверку настоящего родителя мы нашли или так &quot;погулять вышедшего&quot; :)]]></description>
        <author>Riply</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1756568</guid>
        <pubDate>Thu, 08 Nov 2007 09:54:47 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1756568</link>
        <description><![CDATA[Rennigth: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
PS: Закройте его тогда уж, хотя бы, dwProcessHandle в смысле... <br>
</div></div><br>
<br>
Сорь :), поправил предыдущий пост чтоб не плодить одно и тоже.]]></description>
        <author>Rennigth</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1756560</guid>
        <pubDate>Thu, 08 Nov 2007 09:50:44 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1756560</link>
        <description><![CDATA[Rose: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Кстати пока отлаживал, псевдохендл не всегда отрабатывал(закономерности не понял), и NtQueryInformationProcess выкидывало с &quot;неверный декриптор&quot;. Пришлось DublicateHandle все-таки оставить.</div></div><br>
<br>
Честно говоря, не сталкивался с проблемами из-за псевдохэндла, но раз так, то буду иметь в виду.<br>
<br>
PS: Закройте его тогда уж, хотя бы, dwProcessHandle в смысле...]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1756540</guid>
        <pubDate>Thu, 08 Nov 2007 09:35:55 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1756540</link>
        <description><![CDATA[Rennigth: Вобщем если я правильно понял автору нужно что-то врое этого:<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp;ProcessBasicInformation = 0;</div><div class="code_line">&nbsp;&nbsp;CSIDL_PROGRAM_FILES = {text}26;</div><div class="code_line">&nbsp;&nbsp;IExplorePath: string = &#39;\Internet Explorer\IEXPLORE.EXE&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp;PROCESS_BASIC_INFORMATION = packed record</div><div class="code_line">&nbsp;&nbsp; &nbsp;ExitStatus: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PebBaseAddress: Pointer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;AffinityMask: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;BasePriority: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;uUniqueProcessId: Ulong;</div><div class="code_line">&nbsp;&nbsp; &nbsp;uInheritedFromUniqueProcessId: Ulong;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;</div><div class="code_line">function &nbsp;NtQueryInformationProcess(</div><div class="code_line">&nbsp;&nbsp;ProcessHandle : THandle;</div><div class="code_line">&nbsp;&nbsp;ProcessInformationClass : Byte;</div><div class="code_line">&nbsp;&nbsp;ProcessInformation : Pointer;</div><div class="code_line">&nbsp;&nbsp;ProcessInformationLength : ULONG;</div><div class="code_line">&nbsp;&nbsp;ReturnLength : PULONG</div><div class="code_line">&nbsp;&nbsp;): DWORD; stdcall; external &#39;ntdll.dll&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">function GetModuleFileNameExA(</div><div class="code_line">&nbsp;&nbsp;hProcess: DWORD;</div><div class="code_line">&nbsp;&nbsp;hModule: DWORD;</div><div class="code_line">&nbsp;&nbsp;lpFilename: PAnsiChar;</div><div class="code_line">&nbsp;&nbsp;nSize: DWORD</div><div class="code_line">&nbsp;&nbsp;): DWORD; stdcall; external &#39;PSAPI.dll&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">function OwnerProcessIs_IExplore: Boolean;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;lInfo: PROCESS_BASIC_INFORMATION;</div><div class="code_line">&nbsp;&nbsp;lParentProcHandle: THandle;</div><div class="code_line">&nbsp;&nbsp;lpFileName, lPFPath: PAnsiChar;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;dwProcessHandle: DWORD;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;Result := False;</div><div class="code_line">&nbsp;&nbsp;ZeroMemory(@lInfo, SizeOf(PROCESS_BASIC_INFORMATION));</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;DuplicateHandle(GetCurrentProcess, GetCurrentProcess, GetCurrentProcess,</div><div class="code_line">&nbsp;&nbsp; &nbsp;@dwProcessHandle, 0, False, DUPLICATE_SAME_ACCESS);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;if NtQueryInformationProcess(dwProcessHandle, ProcessBasicInformation,</div><div class="code_line">&nbsp;&nbsp; &nbsp;@lInfo, SizeOf(PROCESS_BASIC_INFORMATION), nil) = NO_ERROR then</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;lParentProcHandle := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ,</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; False, lInfo.uInheritedFromUniqueProcessId);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if lParentProcHandle &#62; 0 then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;lpFileName := GetMemory(MAX_PATH);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;ZeroMemory(lpFileName, MAX_PATH);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;lPFPath := GetMemory(MAX_PATH);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;ZeroMemory(lPFPath, MAX_PATH);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if SHGetSpecialFolderPath(0, lPFPath, CSIDL_PROGRAM_FILES, False) and</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(GetModuleFileNameExA(lParentProcHandle, 0, lpFileName, MAX_PATH) &#62; 0) then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Result := lPFPath + IExplorePath = lpFileName;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;FreeMemory(lpFileName);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;FreeMemory(lPFPath);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp;CloseHandle(lParentProcHandle);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;&nbsp;CloseHandle(dwProcessHandle);</div><div class="code_line">end;</div></ol></div></div></div></div> <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-08T09:40:11+00:00">08.11.07, 09:40</time></span></span><br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
  DuplicateHandle не обязательно. NtQueryInformationProcess прекрасно съедает и псевдохэндл. <br>
</div></div><br>
Кстати пока отлаживал, псевдохендл не всегда отрабатывал(закономерности не понял), и NtQueryInformationProcess выкидывало с &quot;неверный декриптор&quot;. Пришлось DublicateHandle все-таки оставить.]]></description>
        <author>Rennigth</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755985</guid>
        <pubDate>Wed, 07 Nov 2007 19:45:10 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755985</link>
        <description><![CDATA[Rouse_: Тэкссс... тебе уже много насоветовали. Давай сначала посмотрим, понял ли ты все это. Выкладывай аттачем код, с которым сейчас эксперементируешь...]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755973</guid>
        <pubDate>Wed, 07 Nov 2007 19:36:29 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755973</link>
        <description><![CDATA[SOLON7: А какой же быстрый способ узнать по ПИДУ имя процесса.<br>Какую функцию по обьему кода посоветуете????<br>Чтоб поменьше кода было....]]></description>
        <author>SOLON7</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755891</guid>
        <pubDate>Wed, 07 Nov 2007 17:51:13 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755891</link>
        <description><![CDATA[Rouse_: GetModuleFileNameEx очевидно :)]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755799</guid>
        <pubDate>Wed, 07 Nov 2007 15:58:16 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1755799</link>
        <description><![CDATA[SOLON7: НУ родителя мы то узнаем, а как узнать является ли процесс Internet Explorer....]]></description>
        <author>SOLON7</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1754102</guid>
        <pubDate>Tue, 06 Nov 2007 13:00:48 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1754102</link>
        <description><![CDATA[Riply: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1753628'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Rouse_ &#064; <time class="tag-quote__quoted-time" datetime="2007-11-06T08:41:24+00:00">06.11.07, 08:41</time></span><div class='quote '>Узнать родителя любого процесса можно и без перебора процессов в снимке. Например вот так:</div></div><br>
А мы не привыкли искать легкие пути :)<br>
А если серьезно, то мне это просто не пришло в голову.<br>
Спасибо.]]></description>
        <author>Riply</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753657</guid>
        <pubDate>Tue, 06 Nov 2007 08:58:03 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753657</link>
        <description><![CDATA[Rouse_: <strong class='tag-b'>Rose</strong>, согласен...]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753651</guid>
        <pubDate>Tue, 06 Nov 2007 08:53:45 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753651</link>
        <description><![CDATA[Rose: <strong class='tag-b'>Rouse_</strong><br>
<br>
DuplicateHandle не обязательно. NtQueryInformationProcess прекрасно съедает и псевдохэндл.]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753628</guid>
        <pubDate>Tue, 06 Nov 2007 08:41:24 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753628</link>
        <description><![CDATA[Rouse_: Узнать родителя любого процесса можно и без перебора процессов в снимке. Например вот так:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">type</div><div class="code_line">&nbsp;&nbsp;PROCESS_BASIC_INFORMATION = packed record</div><div class="code_line">&nbsp;&nbsp; &nbsp;ExitStatus: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;PebBaseAddress: Pointer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;AffinityMask: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;BasePriority: DWORD;</div><div class="code_line">&nbsp;&nbsp; &nbsp;uUniqueProcessId: Ulong;</div><div class="code_line">&nbsp;&nbsp; &nbsp;uInheritedFromUniqueProcessId: Ulong;</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;</div><div class="code_line">function &nbsp;NtQueryInformationProcess(</div><div class="code_line">&nbsp;&nbsp; &nbsp;ProcessHandle : THandle;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ProcessInformationClass : Byte;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ProcessInformation : Pointer;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ProcessInformationLength : ULONG;</div><div class="code_line">&nbsp;&nbsp; &nbsp;ReturnLength : PULONG</div><div class="code_line">&nbsp;&nbsp;): DWORD; stdcall; external &#39;ntdll.dll&#39;;</div><div class="code_line">&nbsp;</div><div class="code_line">function GetOwnedProcessID(const dwProcessHandle: DWORD): DWORD;</div><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp;ProcessBasicInformation = 0;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;Info: PROCESS_BASIC_INFORMATION;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;Result := 0;</div><div class="code_line">&nbsp;&nbsp;if NtQueryInformationProcess(dwProcessHandle,</div><div class="code_line">&nbsp;&nbsp; &nbsp;ProcessBasicInformation, @Info, SizeOf(Info), nil) = NO_ERROR then</div><div class="code_line">&nbsp;&nbsp; &nbsp;Result := Info.uInheritedFromUniqueProcessId;</div><div class="code_line">end;</div></ol></div></div></div></div><br>
<br>
Вот так будет выглядеть получение родителя от текущего процесса:<br>
<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">procedure TForm1.Button1Click(Sender: TObject);</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;dwProcessHandle: DWORD;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;DuplicateHandle(GetCurrentProcess, GetCurrentProcess, GetCurrentProcess,</div><div class="code_line">&nbsp;&nbsp; &nbsp;@dwProcessHandle, 0, False, DUPLICATE_SAME_ACCESS);</div><div class="code_line">&nbsp;&nbsp;Caption := IntToStr(GetOwnedProcessID(dwProcessHandle));</div><div class="code_line">end;</div></ol></div></div></div></div>]]></description>
        <author>Rouse_</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753513</guid>
        <pubDate>Tue, 06 Nov 2007 07:35:20 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753513</link>
        <description><![CDATA[Rose: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Да вы что, а разве PID не растет с каждым новым запуском нового процесса, как-то не вяжется, чтобы PID был одинаков у процессов</div></div><br>
<br>
Riply абсолютно права. Я к сожелению не смог найти прямого ответа в MSDN, там весьма уклончиво отвечают на этот вопрос - &quot;<em class='tag-i'>The identifier is valid from the time the process is created until the process has been terminated</em>.&quot; Эту фразу, в принципе, можно понять по разному. Зато недвусмысленно это описано у Рихтера, так что сошлемся на его авторитет: <br>
<br>
<em class='tag-i'>Подчеркну ещс один чрезвычайно важный момент система способна повторно использовать идентификаторы процессов и потоков. Например, при создании про цесса система формирует объект &quot;процесс&quot;, присваивая ему идентификатор со зна чением, допустим, 122 Создавая новый объект &quot;процесс&quot;, система уже не присвоит ему данный идентификатор. Но после выгрузки из памяти первого объекта следу ющему создаваемому объекту &quot;процесс&quot; может быть присвоен тот же идентификатор — 122. <br>
<br>
Эту особенность нужно учитывать при написании кода, избегая ссылок на невер ный объект &quot;процесс&quot; (или &quot;поток&quot;). Действительно, затребовать и сохранить иден тификатор процесса несложно, но задумайтесь, что получится, ссли в следующий момент этот процесс будет завершен, а новый получит тот же идентификатор: сохра ненный ранее идентификатор уже связан совсем с другим процессом.</em>]]></description>
        <author>Rose</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753501</guid>
        <pubDate>Tue, 06 Nov 2007 07:28:37 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753501</link>
        <description><![CDATA[Riply: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1753366'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>SOLON7 &#064; <time class="tag-quote__quoted-time" datetime="2007-11-06T02:27:41+00:00">06.11.07, 02:27</time></span><div class='quote '>Да вы что, а разве PID не растет с каждым новым запуском нового процесса</div></div><br>
Нет. В общем случае это не так.<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1753366'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>SOLON7 &#064; <time class="tag-quote__quoted-time" datetime="2007-11-06T02:27:41+00:00">06.11.07, 02:27</time></span><div class='quote '>как-то не вяжется, чтобы PID был одинаков у процессов</div></div><br>
У двух процессов, существовавших одновременно в некий момент времени, одинаковых ID быть не может.<br>
Но эта ситуация вполне реальна, для процессов, разнесенных во времени.<br>
Кстати, вероятность этого не так уж мала, как кажется.<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1753366'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>SOLON7 &#064; <time class="tag-quote__quoted-time" datetime="2007-11-06T02:27:41+00:00">06.11.07, 02:27</time></span><div class='quote '>Я нашел пожалуй самый легкий метод определения, как узнавать запущенна ли прога из интернет експлорер.<br>
При запуске из ИНтернет Експолера не передаеться параметр &quot;Рабочий каталог&quot;. То есть можно проверить если рабочий каталог неравен Extractfilepath(paramstr(0)) то значит его запустил ИНтернет Експолера</div></div><br>
Этот способ определения череват ошибками, imho. Ибо из факта &quot;если рабочий каталог неравен Extractfilepath(paramstr(0))&quot;<br>
отнюдь не следует, что нас запустил IE. :)]]></description>
        <author>Riply</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753366</guid>
        <pubDate>Tue, 06 Nov 2007 02:27:41 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753366</link>
        <description><![CDATA[SOLON7: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1753364'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Riply &#064; <time class="tag-quote__quoted-time" datetime="2007-11-06T01:15:46+00:00">06.11.07, 01:15</time></span><div class='quote '>Забыла еще одну неприятную вещь:<br>
Может получиться так, что к моменту нашего поиска, родитель уже умрет,<br>
и будет создан другой процесс с такм же ID, как и у родителя.</div></div><br>
<br>
Да вы что, а разве PID не растет с каждым новым запуском нового процесса, как-то не вяжется, чтобы PID был одинаков у процессов, это было по крайне мере глупо со стороны MICROSOFT делать такое.<br>
Процесса может быть уже убит, но чтобы pid были одинаковы не вериться... <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-06T02:34:55+00:00">06.11.07, 02:34</time></span></span><br>
Я нашел пожалуй самый легкий метод определения, как узнавать запущенна ли прога из интернет експлорер.<br>
<br>
При запуске из ИНтернет Експолера не передаеться параметр &quot;Рабочий каталог&quot;. То есть можно проверить если рабочий каталог неравен Extractfilepath(paramstr(0)) то значит его запустил ИНтернет Експолера. Да твик не гибкий, но простой и не требующих мозломства.<br>
<br>
RIPLY, а вы что преподователь, изложили все в такой форме, красиво. Мне кажеться вы преподователь, или по крайне мере имеете его задатки...<br>
<br>
<strong class='tag-b'>ВСЕМ СПАСИБО ПЛАН РАБОТЫ НАМЕЧЕН, БУДЕМ РАБОТАТАТЬ.</strong>]]></description>
        <author>SOLON7</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753364</guid>
        <pubDate>Tue, 06 Nov 2007 01:15:46 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753364</link>
        <description><![CDATA[Riply: Ничего не поняла насчет &quot;плагин для Internet explorer&#39;а&quot; и &quot;не гибкости Internet explorer&quot; :)<br>
Посему, попробую ответить на &quot;Тоесть узнать имя процесса запустившего мою программу.&quot;<br>
Раз любишь задачки, то вот для затравки набросала ф-ию поиска ID родителя:<br>
(не тестировала)<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">function GetMyParentID(var ParentID: DWord): DWord;</div><div class="code_line">var</div><div class="code_line">&nbsp;ProcEntry: TProcessEntry32;</div><div class="code_line">&nbsp;hSnapshot: THandle;</div><div class="code_line">&nbsp;CurrID: DWord;</div><div class="code_line">&nbsp;_OK: Boolean;</div><div class="code_line">begin</div><div class="code_line">&nbsp;hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);</div><div class="code_line">&nbsp;if hSnapshot &#60;&#62; INVALID_HANDLE_VALUE then</div><div class="code_line">&nbsp;&nbsp;try</div><div class="code_line">&nbsp;&nbsp; ProcEntry.dwSize := SizeOf(ProcEntry);</div><div class="code_line">&nbsp;&nbsp; _OK := Process32First(hSnapshot, ProcEntry);</div><div class="code_line">&nbsp;&nbsp; if _OK then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; CurrID := GetCurrentProcessId;</div><div class="code_line">&nbsp;&nbsp; &nbsp; SetLastError(ERROR_SUCCESS);</div><div class="code_line">&nbsp;&nbsp; &nbsp; while _OK do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if ProcEntry.th32ProcessID = CurrID then</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;ParentID := ProcEntry.th32ParentProcessID;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; end</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else _OK := Process32Next(hSnapshot, ProcEntry);</div><div class="code_line">&nbsp;&nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; Result := GetLastError;</div><div class="code_line">&nbsp;&nbsp;finally</div><div class="code_line">&nbsp;&nbsp; CloseHandle(hSnapshot);</div><div class="code_line">&nbsp;&nbsp;end</div><div class="code_line">&nbsp;else Result := GetLastError;</div><div class="code_line">end;</div></ol></div></div></div></div><br>
Ну а чуть-чуть ее видоизменить для нахождения имени родителя по его ID<br>
оставляю в качестве домашего задания :)<br>
<br>
P.S.<br>
Только проку от данной методики, как от козла молока.<br>
Процесса родителя уже может и не быть в помине, пока мы тут соизволяем его искать :)<br>
И полученный нами ID, можно выбрасывать на помойку.<br>
<br>
Гораздо лучше использовать NtQuerySystemInformation с <br>
параметром SystemProcessesAndThreadsInformation - можно обойтись одним &quot;снимком&quot;.<br>
Правда и с CreateToolhelp32Snapshot можно, но придется запоминать ProcEntry`ы. <br>
<br>
P.S.S.<br>
&gt;Да нет с TlHelp32 работал<br>
&gt;Я люблю, когда появляються задачи по программированию.. <br>
&gt;Но тут немного в невиддении насчет родителя.. <br>
Ой как &quot;не вяжутся&quot; эти три фразы :) <br>
(особенно учитывая, что в Help`е есть пример :)<br>
<br>
Забыла еще одну неприятную вещь:<br>
Может получиться так, что к моменту нашего поиска, родитель уже умрет,<br>
и будет создан другой процесс с такм же ID, как и у родителя.<br>
А вот чтобы не попасть впросак с этим, придется использовать NtQuerySystemInformation<br>
и сравнивать времена создания найденого нами родителя и наше.]]></description>
        <author>Riply</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753289</guid>
        <pubDate>Mon, 05 Nov 2007 21:35:47 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753289</link>
        <description><![CDATA[Брежнев: Да в плагины гораздо логичнее передавать какой-то интерфейс (не обязательно в прямом смысле слова) основного приложения, а не хаками это определять.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=209024&view=findpost&p=1753154'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>SOLON7 &#064; <time class="tag-quote__quoted-time" datetime="2007-11-05T19:07:38+00:00">05.11.07, 19:07</time></span><div class='quote '>то есть не гибкий однако Internet explorer</div></div><br>
Да что вы говорите, с каких это пор динамические библиотеки (DLL) стали запускаться с параметрами коммандной строки? <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-05T21:36:55+00:00">05.11.07, 21:36</time></span></span><br>
Где в LoadLibrary вы увидели параметры коммандной строки?]]></description>
        <author>Брежнев</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753154</guid>
        <pubDate>Mon, 05 Nov 2007 19:07:38 +0000</pubDate>
        <title>Как узнать процесс родителя.</title>
        <link>https://forum.sources.ru/index.php?showtopic=209024&amp;view=findpost&amp;p=1753154</link>
        <description><![CDATA[SOLON7: Господа вопрос такой. Есть процесс.<br>
Как узнать процесс родителя.<br>
Тоесть узнать имя процесса запустившего мою программу.<br>
<br>
Хотел написать плагин для Internet explorer&#39;а, где если бы программа запускалась с параметром -d то сразу программа определяла что программу запустил Internet explorer,ан нет оказываеться нет. Там в ветви Software&#092;Microsoft&#092;Internet Explorer&#092;Extensions, добавляються программы на исполнение, без дополнительных параметров, то есть не гибкий однако Internet explorer.<br>
<br>
Вопрос: Может есть у кого наработки на узнавание родителя процесса.<br>
<br>
Спросите вы, что мне лень. Да нет с TlHelp32 работал, просто чьйто наработки могут быть полезны для меня, и для других, кто дальше столкнеться с данной проблемой... <br>
<br>
<span class="tag-color tag-color-named" data-value="gray" style="color: gray"><span class='tag-size' data-value='7' style='font-size:7pt;'>Добавлено <time class="tag-mergetime" datetime="2007-11-05T19:09:48+00:00">05.11.07, 19:09</time></span></span><br>
Я люблю, когда появляються задачи по программированию.. Но тут немного в невиддении насчет родителя..]]></description>
        <author>SOLON7</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      </channel>
      </rss>
	