<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: определить версию Windows]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5295&amp;type=atom" />
	<updated>2010-12-26T17:52:03Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5295</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=43068#p43068" />
			<content type="html"><![CDATA[<p><a href="http://www.autohotkey.com/forum/viewtopic.php?t=8606&amp;postdays=0&amp;postorder=asc&amp;start=0&amp;sid=7ac52f66c762fd2fc9698b736942d931">Есть</a> возможность сохранять вывод из cmd непосредственно в переменную, без создания дополнительных файлов. Немного модифицированный мною вариант:<br /></p><div class="codebox"><pre><code>Output := CMDret_RunReturn(&quot;cmd /c ver&quot;)
DllCall(&quot;OemToChar&quot;, &quot;Str&quot;, Output, &quot;Str&quot;, Output)   ; эта строка нужна, если в выводе присутствует кириллица
MsgBox, % Output
Return

CMDret_RunReturn(CMDin)
{
  Global cmdretPID   ; for external abort
  dly := (A_BatchLines &lt;&gt; -1) * 50 ; needs longer delay when Batchlines &lt;&gt; -1

  VarSetCapacity(lpBuffer,1024)
  VarSetCapacity(sui,68, 0)
  VarSetCapacity(pi, 16, 0)
  VarSetCapacity(pa, 12, 0)
  NumPut( 12, pa, 0)
  NumPut( 1,  pa, 8)

  IF (DllCall(&quot;CreatePipe&quot;, &quot;UInt*&quot;,hRead, &quot;UInt*&quot;,hWrite, UInt,&amp;pa, Int,0) &lt;&gt; 0) {
    NumPut(68,    sui, 0 )
    DllCall(&quot;GetStartupInfo&quot;, &quot;UInt&quot;, &amp;sui)
    NumPut(0x101, sui, 44)
    NumPut(0,     sui, 48)
    NumPut(hWrite,sui, 60)
    NumPut(hWrite,sui, 64)

    IF (DllCall(&quot;CreateProcess&quot;,Int,0,Str,CMDin,Int,0,Int,0,Int,1,UInt,0,Int,0,Int,0,UInt,&amp;sui,UInt,&amp;pi)&lt;&gt;0) {
      cmdretPID := NumGet(pi, 8)
      Loop {
        IF DllCall(&quot;PeekNamedPipe&quot;,uint,hRead, uint,0, uint,0, uint,0, &quot;UInt*&quot;,bSize, uint,0) = 0
          break
        Process Exist, %cmdretPID%
        If (ErrorLevel = 0 and bsize = 0)
          break
        If (bsize = 0) {
          Sleep %dly% ; only sleep before early continue
          Continue
        }
        VarSetCapacity(lpBuffer, bSize, 0)
        IF (DllCall(&quot;ReadFile&quot;,UInt,hRead, Str,lpBuffer, Int,bSize, &quot;UInt*&quot;,bRead, Int,0) &gt; 0) {
          IFEqual bRead,0, Continue
          CMDout = %CMDout%%lpBuffer%
          }
      } ; Loop
      cmdretPID =
    } ; IF CreateProcess

    DllCall(&quot;CloseHandle&quot;, UInt, hWrite)
    DllCall(&quot;CloseHandle&quot;, UInt, hRead)
  } ; IF CreatePipe

  Return CMDout
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-26T17:52:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=43068#p43068</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=43029#p43029" />
			<content type="html"><![CDATA[<p>Это рабочий вариант.<br />Спасибо.</p>]]></content>
			<author>
				<name><![CDATA[InFlames]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24849</uri>
			</author>
			<updated>2010-12-25T16:49:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=43029#p43029</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=43019#p43019" />
			<content type="html"><![CDATA[<p>Оказывается, cmd записывает в файл два переноса строки, один перед значением, другой после:<br /></p><div class="codebox"><pre><code>RunWait, cmd /c ver &gt; %A_Temp%\ver,, Hide
FileRead, ver, %A_Temp%\ver
FileDelete, %A_Temp%\ver
DllCall(&quot;OemToChar&quot;, &quot;Str&quot;, ver, &quot;Str&quot;, ver)
MsgBox, % &quot;[&quot; ver &quot;]&quot;</code></pre></div><p>Попробуй так:<br /></p><div class="codebox"><pre><code>RunWait, cmd /c Ver &gt; %A_Temp%\OsVer,, Hide
FileRead, OsVer, %A_Temp%\OsVer
FileDelete, %A_Temp%\OsVer
DllCall(&quot;OemToChar&quot;, &quot;Str&quot;, OsVer, &quot;Str&quot;, OsVer)
ver := RegExReplace(OsVer, &quot;s).*?(\d\.\d).*&quot;, &quot;$1&quot;)
MsgBox, % ver = 5.1 ? &quot;xp&quot; : ver = 6.1 ? &quot;win7&quot; : &quot;другая ОС&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-25T15:11:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=43019#p43019</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=43003#p43003" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong><br /></p><div class="codebox"><pre><code>Microsoft Windows [Version 6.1.7600]</code></pre></div><p><strong>ypppu</strong><br />Да, есть.</p>]]></content>
			<author>
				<name><![CDATA[InFlames]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24849</uri>
			</author>
			<updated>2010-12-25T06:33:51Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=43003#p43003</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=43001#p43001" />
			<content type="html"><![CDATA[<p>А в Windows 7 есть Program Files\Common Files\Microsoft Shared\MSInfo\msinfo32.exe ?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2010-12-24T21:29:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=43001#p43001</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42998#p42998" />
			<content type="html"><![CDATA[<p>А у тебя что выдаёт этот скрипт?<br /></p><div class="codebox"><pre><code>RunWait, cmd /c ver &gt; %A_Temp%\ver,, Hide
FileRead, ver, %A_Temp%\ver
FileDelete, %A_Temp%\ver
DllCall(&quot;OemToChar&quot;, &quot;Str&quot;, ver, &quot;Str&quot;, ver)
MsgBox, % ver</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-24T19:45:53Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42998#p42998</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42997#p42997" />
			<content type="html"><![CDATA[<p>В каком виде получается результат? Я так понимаю, что это не число после &quot;Version&quot;, а какой-то текст.<br />Вот такой код показывает, что у меня XP, хотя у меня Win7.<br />Т.е. полученная &quot;6&quot; через RegExReplace не является числом.</p><div class="codebox"><pre><code>RunWait, cmd /c Ver &gt; %A_Temp%\OsVer,, Hide
FileRead, OsVer, %A_Temp%\OsVer
FileDelete, %A_Temp%\OsVer
DllCall(&quot;OemToChar&quot;, &quot;Str&quot;, OsVer, &quot;Str&quot;, OsVer)
MsgBox % RegExReplace(OsVer,&quot;.*Version\s(\d).+&quot;,&quot;$1&quot;) = 6 ? &quot;win7&quot; : &quot;xp&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[InFlames]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24849</uri>
			</author>
			<updated>2010-12-24T19:27:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42997#p42997</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42996#p42996" />
			<content type="html"><![CDATA[<p>Microsoft Windows XP [Версия 5.1.2600]</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-24T18:59:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42996#p42996</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42995#p42995" />
			<content type="html"><![CDATA[<p>А вот это уже рабочий вариант. Спасибо.<br />Если не затруднит, напишите, что выдает этот скрипт на WinXP?</p>]]></content>
			<author>
				<name><![CDATA[InFlames]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24849</uri>
			</author>
			<updated>2010-12-24T18:58:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42995#p42995</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42994#p42994" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>InFlames пишет:</cite><blockquote><p>Autohotkey.exe запускается в режиме совместимости с WinXP SP3.</p></blockquote></div><p>В этом, видимо, и проблема.<br />Можно ещё через cmd:<br /></p><div class="codebox"><pre><code>RunWait, cmd /c ver &gt; %A_Temp%\ver,, Hide
FileRead, ver, %A_Temp%\ver
FileDelete, %A_Temp%\ver
DllCall(&quot;OemToChar&quot;, &quot;Str&quot;, ver, &quot;Str&quot;, ver)
MsgBox, % ver</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-24T18:53:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42994#p42994</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42993#p42993" />
			<content type="html"><![CDATA[<p>Показывает 5.1.2600.<br />Это WinXP.<br />У меня стоит Win7.<br />Autohotkey.exe запускается в режиме совместимости с WinXP SP3.</p>]]></content>
			<author>
				<name><![CDATA[InFlames]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24849</uri>
			</author>
			<updated>2010-12-24T18:38:50Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42993#p42993</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42991#p42991" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>InFlames пишет:</cite><blockquote><p><strong>teadrinker</strong>, если запускать ahk на Win7 в режиме совместимости с XP, то покажет, что это XP, а не семерка</p></blockquote></div><p>Не понял, что &quot;покажет&quot;? Ты скрипт по ссылке запускал?<br /></p><div class="codebox"><pre><code>MsgBox % GetOSVersion()

GetOSVersion() {
    VarSetCapacity(v,148), NumPut(148,v)
    DllCall(&quot;GetVersionEx&quot;, &quot;uint&quot;, &amp;v)
    ; Return formatted version string similar to A_AhkVersion.
    ; Assume build number will never be more than 4 characters.
    return    NumGet(v,4) ; major
        . &quot;.&quot; NumGet(v,8) ; minor
        . &quot;.&quot; SubStr(&quot;0000&quot; NumGet(v,12), -3) ; build
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-24T18:21:32Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42991#p42991</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42990#p42990" />
			<content type="html"><![CDATA[<p><strong>teadrinker</strong>, если запускать ahk на Win7 в режиме совместимости с XP, то покажет, что это XP, а не семерка<br />(только сейчас понял: в первом посте я написал, что на семерке показывает, что это ХР, это как раз из-за запуска ahk в режиме совместимости)</p><p><strong>armenxxx1</strong>, мне бы средствами ahk</p><p>Неужели нет простого способа на ahk отличить семерку и XP?</p>]]></content>
			<author>
				<name><![CDATA[InFlames]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24849</uri>
			</author>
			<updated>2010-12-24T18:17:52Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42990#p42990</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42978#p42978" />
			<content type="html"><![CDATA[<p><a href="http://forum.script-coding.com/viewtopic.php?id=4573">http://forum.script-coding.com/viewtopic.php?id=4573</a></p>]]></content>
			<author>
				<name><![CDATA[armenxxx1]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26102</uri>
			</author>
			<updated>2010-12-24T14:14:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42978#p42978</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: определить версию Windows]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42974#p42974" />
			<content type="html"><![CDATA[<p><a href="http://www.autohotkey.com/forum/topic49168.html#316426">http://www.autohotkey.com/forum/topic49168.html#316426</a><br />Номера версий <a href="http://msdn.microsoft.com/en-us/library/ms724832%28VS.85%29.aspx">здесь</a>.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2010-12-24T10:14:13Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42974#p42974</id>
		</entry>
</feed>
