<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: RegisterCallback() и количество параметров]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=17403&amp;type=atom" />
	<updated>2022-10-07T16:16:49Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=17403</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155116#p155116" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>И если функция уберет 1 параметр вместо 2, то чем это чревато?</p></blockquote></div><p>Зависит от того, как код скомпилировался. Может, и ничего. Смотря от чего, например, адресуются локальные переменные, они ведь хранятся в стеке. Если от указателя стека, то он после вызова окажется не там, где был до вызова, и адресация собьётся.</p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>А почему на 64 битах такой ситуации не наблюдается?</p></blockquote></div><p>Там соглашение вызова fastcall, где стек очищает вызывающая функция. Сколько положила, столько и уберёт.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2022-10-07T16:16:49Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155116#p155116</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155112#p155112" />
			<content type="html"><![CDATA[<p>А почему на 64 битах такой ситуации не наблюдается?<br />И если функция уберет 1 параметр вместо 2, то чем это чревато?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-10-07T15:48:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155112#p155112</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155086#p155086" />
			<content type="html"><![CDATA[<p>Вызванная функция должна сама очищать стек от своих параметров (если соглашение вызова stdcall). Фактически в стеке 2 параметра, а функция уберёт 5, т.е. удалит лишнее.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2022-10-07T02:18:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155086#p155086</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155082#p155082" />
			<content type="html"><![CDATA[<p>Да, в этом случае функция просто крашится:<br /></p><div class="codebox"><pre><code>counter := 0
EnumAddress := RegisterCallback(&quot;EnumWindowsProc&quot;, &quot;Fast&quot;)
MsgBox, % DllCall(&quot;EnumWindows&quot;, &quot;Ptr&quot;, EnumAddress, &quot;Ptr&quot;, 0)
MsgBox %Output%  ; Display the information accumulated by the callback.
    
EnumWindowsProc(hwnd, lParam, a, b, c)   ; 5 параметров вместо 2
{
    global Output, counter
    ToolTip % ++counter
    WinGetClass, class, ahk_id %hwnd%
    WinGetTitle, title, ahk_id %hwnd%
    
    if title
        Output .= &quot;HWND: &quot; . hwnd . &quot;`tTitle: &quot; . title . &quot;`tClass: &quot; . class . &quot;`n&quot;
    return true  ; Tell EnumWindows() to continue until all windows have been enumerated.
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-10-06T20:35:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155082#p155082</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155081#p155081" />
			<content type="html"><![CDATA[<p>Сейчас проверил код из первого поста на 32бит и если параметров больше, то выводит пустоту.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-10-06T19:57:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155081#p155081</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155080#p155080" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>иначе просто интерпретатор выдаст ошибку</p></blockquote></div><p>Проверил, не выдаёт. Просто не сработает:<br /></p><div class="codebox"><pre><code>EnumAddress := RegisterCallback(&quot;EnumWindowsProc&quot;, &quot;Fast&quot;, 3)
DllCall(&quot;EnumWindows&quot;, &quot;Ptr&quot;, EnumAddress, &quot;Ptr&quot;, 0)
MsgBox %Output%  ; Display the information accumulated by the callback.
    
EnumWindowsProc(hwnd, lParam)
{
    global Output
    WinGetTitle, title, ahk_id %hwnd%
    WinGetClass, class, ahk_id %hwnd%
    if title
        Output .= &quot;HWND: &quot; . hwnd . &quot;`tTitle: &quot; . title . &quot;`tClass: &quot; . class . &quot;`n&quot;
    return true  ; Tell EnumWindows() to continue until all windows have been enumerated.
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-10-06T19:47:48Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155080#p155080</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155079#p155079" />
			<content type="html"><![CDATA[<p>В данном случае ничем, лишние просто не будут приходить. Наверно, имеется в виду, что если указано количество, то должно быть правильным, иначе просто интерпретатор выдаст ошибку.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2022-10-06T19:42:04Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155079#p155079</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: RegisterCallback() и количество параметров]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=155078#p155078" />
			<content type="html"><![CDATA[<p>В справке написано, что при создании колбека нужно убедиться, что количество параметров у вызова и принимающей функции должны совпадать.<br />А почему не написано.<br />Чем теоретически может обернуться если их количество совпадать не будет?<br />Например:<br /></p><div class="codebox"><pre><code> EnumAddress := RegisterCallback(&quot;EnumWindowsProc&quot;, &quot;Fast&quot;)
DllCall(&quot;EnumWindows&quot;, &quot;Ptr&quot;, EnumAddress, &quot;Ptr&quot;, 0)
MsgBox %Output%  ; Display the information accumulated by the callback.
    
EnumWindowsProc(hwnd, lParam, temp1, temp2, temp3)   ; 5 параметров вместо 2
{
    global Output
    WinGetTitle, title, ahk_id %hwnd%
    WinGetClass, class, ahk_id %hwnd%
    if title
        Output .= &quot;HWND: &quot; . hwnd . &quot;`tTitle: &quot; . title . &quot;`tClass: &quot; . class . &quot;`n&quot;
    return true  ; Tell EnumWindows() to continue until all windows have been enumerated.
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2022-10-06T19:17:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=155078#p155078</id>
		</entry>
</feed>
