<?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=79692&amp;view=findpost&amp;p=580592</guid>
        <pubDate>Mon, 17 Jan 2005 18:18:53 +0000</pubDate>
        <title>thread creation error insufficient memor</title>
        <link>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=580592</link>
        <description><![CDATA[msn777: &gt;Говоришь под ХР, а как тогда понимать обращение к регистрам? <br><br>&gt;Говоришь под ХР, <br>Пишу по XP, а прога должна работать как под 98, так и под NT.<br><br>&gt;а как тогда понимать обращение к регистрам?<br>Элементарно:<br>   mov eax, Win32Platform – определили тип платформы<br>   cmp eax, VER_PLATFORM_WIN32_NT – проверили это NT<br>   jne @@9X  - если нет то сами генерируем тон<br>   call Windows.Beep – если да то вызвали стандартную пищялку<br>   ret<br>@@9X:]]></description>
        <author>msn777</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=579442</guid>
        <pubDate>Sun, 16 Jan 2005 19:12:13 +0000</pubDate>
        <title>thread creation error insufficient memor</title>
        <link>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=579442</link>
        <description><![CDATA[Anatoly Podgoretsky: Говоришь под ХР, а как тогда понимать обращение к регистрам?]]></description>
        <author>Anatoly Podgoretsky</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=579404</guid>
        <pubDate>Sun, 16 Jan 2005 18:29:08 +0000</pubDate>
        <title>thread creation error insufficient memor</title>
        <link>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=579404</link>
        <description><![CDATA[s-mike: Надо же код выделять тегами. Что в правилах написано?<br>
<div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '><br>
Пожалуйста, выделяйте текст программы тегом [сode=pas] ... [/сode]. Для этого используйте кнопку [code=pas] в форме ответа или комбобокс, если нужно вставить код на языке, отличном от Дельфи/Паскаля.<br>
</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="2005-01-16T18:30:09+00:00">16.01.05, 18:30</time></span></span><br>
На такой код и смотреть не хочется, а не то что изучать.]]></description>
        <author>s-mike</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=579395</guid>
        <pubDate>Sun, 16 Jan 2005 18:23:02 +0000</pubDate>
        <title>thread creation error insufficient memor</title>
        <link>https://forum.sources.ru/index.php?showtopic=79692&amp;view=findpost&amp;p=579395</link>
        <description><![CDATA[msn777: Мастера подскажите, как бороться с “thread creation error: Недостаточно памяти для обработки команды”, говорит, что, мол, мало памяти, хотя под стек выделено 256M  {&#036;M 16384,268435456}, на машине стоит 512М, в диспетчере задач приложение показывает, что для приложения выделено около 5M. Пишу на Delphi 7 под WinXP.<br>
Может, кто сталкивался с такой бедой, из каких соображений принимается решение, что не хватает памяти. До того как в проге было мало элементов (меньше сотни кнопок, меток и т.д.) такое сообщение не выскакивало, сейчас их несколько сотен, такое сообщение выскакивает, после того, как вызываю play_sound для проигрывания wav файла, но ф-н sndPlaySound все время выдает FALSE, хотя перенес этот модуль из старого проекта там все работало, а после этого еще раз play_sound но для пробирования тона, процесс (Thread) созданный sndPlaySound так и остается, а звука нет. Причем если вызывать sndPlaySound с тем же именем файла, но указанным как константа – звук есть, если же переменная (PChar) – звука нет.<br>
<br>
Содержание ComboBox’ов (ItemIndex = -1 если задал имя файла ):<br>
нет<br>
100 Гц, 1 гудок<br>
100 Гц, 2 гудка<br>
200 Гц, 1 гудок<br>
200 Гц, 2 гудка<br>
300 Гц, 1 гудок<br>
300 Гц, 2 гудка<br>
500 Гц, 1 гудок<br>
500 Гц, 2 гудка<br>
700 Гц, 1 гудок<br>
700 Гц, 2 гудка<br>
1000 Гц, 1 гудок<br>
1000 Гц, 2 гудка<br>
1500 Гц, 1 гудок<br>
1500 Гц, 2 гудка<br>
2000 Гц, 1 гудок<br>
2000 Гц, 2 гудка<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; TPlayToneThread = class(TThread) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Поток проигрывания тона</div><div class="code_line">&nbsp;&nbsp; private</div><div class="code_line">&nbsp;&nbsp; &nbsp; Frequency: integer; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Частота тона, Гц</div><div class="code_line">&nbsp;&nbsp; &nbsp; Duration: &nbsp;integer; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Длительность выдачи тона, мс</div><div class="code_line">&nbsp;&nbsp; &nbsp; Count: &nbsp; &nbsp; integer; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Кол-во выдаваемых тонов</div><div class="code_line">&nbsp;&nbsp; protected</div><div class="code_line">&nbsp;&nbsp; &nbsp; procedure Execute; override; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Исполняемая часть</div><div class="code_line">&nbsp;&nbsp; end;</div><div class="code_line">&nbsp;</div><div class="code_line">//----------------------------------- Выдать на динамик тон ----------------------------------------</div><div class="code_line">procedure Sound(Frequency, Duration: Integer);</div><div class="code_line">asm</div><div class="code_line">&nbsp;&nbsp; push edx</div><div class="code_line">&nbsp;&nbsp; push eax</div><div class="code_line">&nbsp;&nbsp; mov eax, Win32Platform</div><div class="code_line">&nbsp;&nbsp; cmp eax, VER_PLATFORM_WIN32_NT</div><div class="code_line">&nbsp;&nbsp; jne @@9X</div><div class="code_line">&nbsp;&nbsp; call Windows.Beep</div><div class="code_line">&nbsp;&nbsp; ret</div><div class="code_line">@@9X:</div><div class="code_line">&nbsp;&nbsp; pop eax</div><div class="code_line">&nbsp;&nbsp; pop edx</div><div class="code_line">&nbsp;&nbsp; push ebx</div><div class="code_line">&nbsp;&nbsp; push edx</div><div class="code_line">&nbsp;&nbsp; mov bx, ax</div><div class="code_line">&nbsp;&nbsp; mov ax, 34DDh</div><div class="code_line">&nbsp;&nbsp; mov dx, 0012h</div><div class="code_line">&nbsp;&nbsp; cmp dx, bx</div><div class="code_line">&nbsp;&nbsp; jnc @@2</div><div class="code_line">&nbsp;&nbsp; div bx</div><div class="code_line">&nbsp;&nbsp; mov bx, ax</div><div class="code_line">&nbsp;&nbsp; in al, 61h</div><div class="code_line">&nbsp;&nbsp; test al, 3</div><div class="code_line">&nbsp;&nbsp; jnz @@1</div><div class="code_line">&nbsp;&nbsp; or al, 3</div><div class="code_line">&nbsp;&nbsp; out 61h, al</div><div class="code_line">&nbsp;&nbsp; mov al, 0B6h</div><div class="code_line">&nbsp;&nbsp; out 43h, al</div><div class="code_line">@@1:</div><div class="code_line">&nbsp;&nbsp; mov al, bl</div><div class="code_line">&nbsp;&nbsp; out 42h, al</div><div class="code_line">&nbsp;&nbsp; mov al, bh</div><div class="code_line">&nbsp;&nbsp; out 42h, al</div><div class="code_line">&nbsp;&nbsp; call Windows.Sleep</div><div class="code_line">&nbsp;&nbsp; in al, 61h</div><div class="code_line">&nbsp;&nbsp; and al, 0FCh</div><div class="code_line">&nbsp;&nbsp; out 61h, al</div><div class="code_line">&nbsp;&nbsp; jmp @@3</div><div class="code_line">@@2:</div><div class="code_line">&nbsp;&nbsp; pop edx</div><div class="code_line">@@3:</div><div class="code_line">&nbsp;&nbsp; pop ebx</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">//--------------------------------- Реализация потока проигрывания тона ----------------------------</div><div class="code_line">procedure TPlayToneThread.Execute;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;FreeOnTerminate:=True; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// По завершению работы освободить память</div><div class="code_line">&nbsp;&nbsp;while Count&#62;0 do</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;Sound(Frequency,Duration);</div><div class="code_line">&nbsp;&nbsp; &nbsp;sleep(Duration);</div><div class="code_line">&nbsp;&nbsp; &nbsp;dec(Count);</div><div class="code_line">&nbsp;&nbsp;end;</div><div class="code_line">&nbsp;&nbsp;Terminate; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// На всяк случай завершаем поток</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">//--------------------------------- Процедура завершения потока ------------------------------------</div><div class="code_line">procedure TfmOSC_Buzzer.end_thread(Sender: TObject);</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;PlayToneThread:=nil; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// На всяк случай уничтожаем объект</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">//-------------------------------------- Проиграть звук --------------------------------------------</div><div class="code_line">procedure TfmOSC_Buzzer.play_sound(cbSound: TComboBox; play: boolean = false);</div><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp;Duration: integer = 75;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;Frequency, Count: integer;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;if cbSound.ItemIndex=0 then exit; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Если нечего проигрывать то выходим</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;if cbSound.ItemIndex&#60;0 then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Если это *.wav файл</div><div class="code_line">&nbsp;&nbsp; &nbsp;try</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;sndPlaySound(PChar(cbSound.Text),SND_ASYNC); &nbsp; &nbsp;// &nbsp;то просто проигрываем его</div><div class="code_line">&nbsp;&nbsp; &nbsp;except</div><div class="code_line">&nbsp;&nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp;else begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;Frequency:=StrToInt(Trim(Copy(cbSound.Text,1,4))); &nbsp;// Определили частоту и кол-во гудков</div><div class="code_line">&nbsp;&nbsp; &nbsp;if Odd(cbSound.ItemIndex) then Count:=1 else Count:=2;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if IsWindowsNT then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if PlayToneThread&#60;&#62;nil then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Если поток существует</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if not PlayToneThread.Terminated then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Да он еще и не завершен</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if play then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Если нужно проиграть</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PlayToneThread.Terminate &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// &nbsp;то завершили поток</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Если событие</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;то выходим</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread:=TPlayToneThread.Create(true); &nbsp; &nbsp; // Создаем поток</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread.OnTerminate:=end_thread; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Задали процедуру завершения</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread.Priority:=tpNormal; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Задаем нормальный приоритет потоку</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread.Frequency:=Frequency;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread.Duration:=Duration;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread.Count:=Count;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;PlayToneThread.Resume; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Запускаем поток</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while Count&#62;0 do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Sound(Frequency,Duration);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;sleep(Duration);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dec(Count);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{}</div><div class="code_line">&nbsp;&nbsp; &nbsp;end</div><div class="code_line">&nbsp;&nbsp; &nbsp;else begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;while Count&#62;0 do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;Sound(Frequency,Duration);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;sleep(Duration);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;dec(Count);</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;end;</div><div class="code_line">end;</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script><br>
<br>
<div class="tag-mod"><div class="tag-mod__prefix">M</div><div class="tag-mod__body">Используем тег code&#33;</div></div>]]></description>
        <author>msn777</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      </channel>
      </rss>
	