<?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=351424&amp;view=findpost&amp;p=3084909</guid>
        <pubDate>Sun, 26 Feb 2012 13:06:06 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3084909</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3081310'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>B.V. &#064; <time class="tag-quote__quoted-time" datetime="2012-02-20T18:44:50+04:00">20.02.12, 14:44</time></span><div class='quote '>Перенеси его, пожалуйста, в первый пост, и тема уйдет в ФАК</div></div><br>
Перенёс.]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3081310</guid>
        <pubDate>Mon, 20 Feb 2012 14:44:50 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3081310</link>
        <description><![CDATA[B.V.: neokoder, не надо так все принимать в штыки<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080916'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>neokoder &#064; <time class="tag-quote__quoted-time" datetime="2012-02-20T06:28:05+00:00">20.02.12, 06:28</time></span><div class='quote '>Полный исходный код</div></div><br>
Перенеси его, пожалуйста, в первый пост, и тема уйдет в ФАК]]></description>
        <author>B.V.</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080956</guid>
        <pubDate>Mon, 20 Feb 2012 07:39:15 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080956</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080943'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>neokoder &#064; <time class="tag-quote__quoted-time" datetime="2012-02-20T07:21:11+00:00">20.02.12, 07:21</time></span><div class='quote '>Ничего плохого в goto нету, холивал бесполезен.</div></div><br>
Убеди в этом Мальчиша. :)]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080953</guid>
        <pubDate>Mon, 20 Feb 2012 07:35:55 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080953</link>
        <description><![CDATA[Dem_max: Ничего плохого в <strong class='tag-b'>goto</strong> нету, холивал бесполезен.]]></description>
        <author>Dem_max</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080943</guid>
        <pubDate>Mon, 20 Feb 2012 07:21:11 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080943</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080941'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Dem_max &#064; <time class="tag-quote__quoted-time" datetime="2012-02-20T07:20:28+00:00">20.02.12, 07:20</time></span><div class='quote '>кстати goto надо было оставить в коде</div></div><br>
Скажи это Мальчишу.]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080941</guid>
        <pubDate>Mon, 20 Feb 2012 07:20:28 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080941</link>
        <description><![CDATA[Dem_max: кстати <strong class='tag-b'>goto</strong> надо было оставить в коде, это самый лучший вариант для всех компиляторов, ибо <strong class='tag-b'>__leave</strong>  поддерживается только Visual Studio.]]></description>
        <author>Dem_max</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080923</guid>
        <pubDate>Mon, 20 Feb 2012 06:35:26 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080923</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>поддержку тех, кто высказывался выше: код - комплит булщит<br>
 помесь WCHAR/TCHAR еще меньшая из твоих проблем<br>
 goto, вложенные if/while&#39;ы фиг знает какого уровня разрывают мозг и воскресное настроение<br>
 парсинг строчек, дорогой, neokoder, можно делать более внятными и вменяемыми методами<br>
 поддерживать такой &quot;КОД&quot;, читать его,разбираться невозможно и крайне утомительно.. нужно неуважать других, чтобы просить их вникнуть в сие творение мысли заблудшей души</div></div><br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080747'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:15:46+00:00">19.02.12, 17:15</time></span><div class='quote '>в код невникал - какой-то он гнилой, я юзал вот это:</div></div><br>
<br>
<br>
<strong class='tag-b'>B.V.</strong>, в следующий раз когда вы вновь удивитесь почему neokoder <em class='tag-i'>в последнее время неоднократно нарушал правила, хамил</em> я вам советую обратить внимание <strong class='tag-b'>на причину</strong>. А если к тем кто хамит первым не применяются никакие меры, я что не имею право <span class='tag-u'>ответить</span> на хамство?]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080916</guid>
        <pubDate>Mon, 20 Feb 2012 06:28:05 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080916</link>
        <description><![CDATA[neokoder: В общем всем любителям обрезанного <strong class='tag-b'>НЕ</strong> универсального и потенциально не безопасного кода(хотя бы иногда обращайте внимание на warnings в вашей студии :yes: ), <strong class='tag-b'>НО</strong> зато понятного, читаемого(надеюсь Мальчиш осилит в этот раз и разберется  :D ) делаю по вашему заказу, пожалуйста. Плюс сделал разбор строки по-другому. Также заменил goto на try/finally/leave и убрал использование безопасных функций StringCchPrintf. <br>
<br>
<br>
<strong class='tag-b'>Полный исходный код</strong><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">#define UNICODE</div><div class="code_line">#define _UNICODE</div><div class="code_line">#include &#60;windows.h&#62;</div><div class="code_line">#include &#60;stdio.h&#62;</div><div class="code_line">#include &#60;conio.h&#62;</div><div class="code_line">#include &#60;locale.h&#62;</div><div class="code_line">#include &#60;WinIoCtl.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">WCHAR* GetElem(WCHAR *ptr,WCHAR delim,WCHAR *buf)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; WCHAR *ptr1=NULL;</div><div class="code_line">&nbsp;&nbsp; ptr1=wcschr(ptr,delim);</div><div class="code_line">&nbsp;&nbsp; if (ptr1)</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wcsncpy(buf,ptr,(int)(ptr1-ptr));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[(int)(ptr1-ptr)]=0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return (ptr1+1);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wcscpy(buf,ptr);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return NULL;</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">//Входные данные:</div><div class="code_line">//IN drive_letter - буква диска</div><div class="code_line">void PrintFlashDriveInfo(WCHAR drive_letter)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; HKEY hk=NULL;</div><div class="code_line">&nbsp;&nbsp; LONG Ret=0;</div><div class="code_line">&nbsp;&nbsp; HANDLE hdrive=INVALID_HANDLE_VALUE;</div><div class="code_line">&nbsp;&nbsp; DWORD data_size,dtype;</div><div class="code_line">&nbsp;&nbsp; WCHAR *data=NULL,*buf1=NULL,*buf2=NULL;</div><div class="code_line">&nbsp;&nbsp; WCHAR *ptr1_1=NULL,*ptr1_2=NULL,*ptr2_1=NULL,*ptr2_2=NULL;</div><div class="code_line">&nbsp;&nbsp; WCHAR dos_link[50];</div><div class="code_line">&nbsp;&nbsp; WCHAR drive_name2[20];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; __try</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;//проверяем существует ли диск в системе</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wsprintf(drive_name2,L&quot;\\.\%c:&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;hdrive = CreateFileW(drive_name2,0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (hdrive==INVALID_HANDLE_VALUE)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка CreateFile: %u\n\n&quot;,GetLastError());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; __leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;CloseHandle(hdrive);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,L&quot;SYSTEM\MountedDevices&quot;,0,KEY_READ,&amp;hk);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (Ret!=ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegOpenKeyEx: %u\n\n&quot;,Ret);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; __leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wsprintf(dos_link,L&quot;\DosDevices\%c:&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Ret=RegQueryValueExW(hk,dos_link,NULL,&amp;dtype,NULL,&amp;data_size);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (Ret==ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; data=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf1=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf2=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if (data==NULL||buf1==NULL||buf2==NULL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка malloc.\n\n&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; memset(data,0,data_size+2);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Ret=RegQueryValueExW(hk,dos_link,NULL,&amp;dtype,(LPBYTE)data,&amp;data_size);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if (Ret!=ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegQueryValueEx: %u\n\n&quot;,Ret);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if(wcsstr(data,L&quot;USBSTOR&quot;)!=NULL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Данные флеш-диска %c:\n&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=GetElem(data,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (ptr1_1)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_2=GetElem(ptr1_1,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=buf1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr2_2=GetElem(ptr1_1,L&#39;&amp;&#39;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wcsstr(buf2,L&quot;Ven_&quot;))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Производитель: %s\n&quot;,buf2+4);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if (wcsstr(buf2,L&quot;Prod_&quot;))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Название продукта: %s\n&quot;,buf2+5);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=ptr2_2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (ptr2_2);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=GetElem(ptr1_2,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=buf1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr2_2=GetElem(ptr1_1,L&#39;&amp;&#39;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wcslen(buf2)&#62;3)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Серийный номер: %s\n&quot;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=ptr2_2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (ptr2_2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }//if USBSTOR</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Диск %c: НЕ является флешкой\n&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegQueryValueEx: %u\n&quot;,Ret);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wprintf(L&quot;\n&quot;);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;&nbsp; __finally</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (data!=NULL) free(data);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (buf1!=NULL) free(buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (buf2!=NULL) free(buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (hk!=NULL) RegCloseKey(hk);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">int wmain(int argc, WCHAR* argv[])</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; setlocale(LC_ALL,&quot;Russian&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;H&#39;);</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;G&#39;);</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;C&#39;);</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;Я&#39;);</div><div class="code_line">&nbsp;&nbsp; </div><div class="code_line">&nbsp;&nbsp; wprintf(L&quot;Нажмите любую клавишу...&quot;);</div><div class="code_line">&nbsp;&nbsp; _getch();</div><div class="code_line">&nbsp;&nbsp; return 0;</div><div class="code_line">}</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script>]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080750</guid>
        <pubDate>Sun, 19 Feb 2012 17:24:54 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080750</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>поддержку тех, кто высказывался выше: код - комплит булщит</div></div><br>
Ну это ваше мнение только.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>помесь WCHAR/TCHAR еще меньшая из твоих проблем</div></div><br>
Здесь нет никакой <em class='tag-i'>помеси</em>. У вас бзик что ли? Или вы вообще не знаете как строятся универсальные приложения с поддержкой UNICODE и без, которая вкл/выкл изменением двух макроопределений.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>goto, вложенные</div></div><br>
Сделано для простоты. Такие примеры есть в MSDN. Не хотелось использовать __try/__finally/_leave(как сам обычно делаю) <span class='tag-u'>в FAQ</span>, а goto он и в африке goto - всем известен.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>if/while&#39;ы фиг знает какого уровня разрывают мозг и воскресное настроение</div></div><br>
<br>
Ну так продемонстрируйте как надо разбирать строку, может у вас действительно будет более наглядный и классный код, исправлю. Честно говоря я делал быстро и не задумывался нд эффективностью. Цель этого кода - <strong class='tag-b'>определить информацию</strong>, это главная задача, а не сделать супер-пупер наилучший пример парсинга строки.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>парсинг строчек, дорогой, neokoder, можно делать более внятными и вменяемыми методами</div></div><br>
Я жду ваш пример.<br>
 <br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '>поддерживать такой &quot;КОД&quot;, читать его,разбираться невозможно и крайне утомительно.. </div></div><br>
Ваше личное мнение.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080746'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Мальчиш &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T17:09:31+00:00">19.02.12, 17:09</time></span><div class='quote '> нужно неуважать других, чтобы просить их вникнуть в сие творение мысли заблудшей души</div></div><br>
О своей заблудшей душе подумайте лучше. <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="2012-02-19T17:54:10+00:00">19.02.12, 17:54</time></span></span><br>
Я вообще не понимаю, тут спецы по синтаксису языка собрались или же важнее чтобы код правильно работал и решал функциональную задачу :-?]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080746</guid>
        <pubDate>Sun, 19 Feb 2012 17:09:31 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080746</link>
        <description><![CDATA[Мальчиш: поддержку тех, кто высказывался выше: код - <span class='tag-u'>комплит булщит</span><br>
помесь WCHAR/TCHAR еще меньшая из твоих проблем<br>
goto, вложенные if/while&#39;ы фиг знает какого уровня разрывают мозг и воскресное настроение<br>
парсинг строчек, дорогой, <strong class='tag-b'>neokoder</strong>, можно делать более внятными и вменяемыми методами<br>
поддерживать такой &quot;КОД&quot;, читать его,разбираться невозможно и крайне утомительно.. нужно неуважать других, чтобы просить их вникнуть в сие творение мысли заблудшей души :whistle:]]></description>
        <author>Мальчиш</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080742</guid>
        <pubDate>Sun, 19 Feb 2012 16:53:57 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080742</link>
        <description><![CDATA[neokoder: Я устал уже доказывать, <strong class='tag-b'>B.V.</strong>. Честное слово. Как в стенку лбом.<br>
<br>
<div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080693'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>neokoder &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T14:45:49+00:00">19.02.12, 14:45</time></span><div class='quote '>Всё остальное универсально, <strong class='tag-b'>настроено на работу как с Юникодом <span class='tag-u'>так и без него</span></strong></div></div><br>
<br>
Почему ты хочешь отнять универсальность кода?]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080731</guid>
        <pubDate>Sun, 19 Feb 2012 16:31:29 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080731</link>
        <description><![CDATA[B.V.: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080693'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>neokoder &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T14:45:49+00:00">19.02.12, 14:45</time></span><div class='quote '>Изначально я и сделал так как ты запрашиваешь, но при выключении юникода функции не будут работать, поскольку в реестре все бинарные данные хранятся в юникоде(по крайней мере у меня на Win7, но думаю что в XP таже).</div></div><br>
Так и переведи весь вывод на юникод, к чему выводить одни сообщения посредством tprintf, а другие -- юникодным wprintf? В рамках данного кода переносимости нет, а отдельные его фрагменты вряд ли кто будет использовать, применение tchar неоправданно]]></description>
        <author>B.V.</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080718</guid>
        <pubDate>Sun, 19 Feb 2012 16:03:44 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080718</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080704'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>Dem_max &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T15:34:56+00:00">19.02.12, 15:34</time></span><div class='quote '>Если нет, тогда убери из исходников это #include &lt;tchar.h&gt; так как у тебя только юникод используется.</div></div><br>
 :) Надо думать прежде чем писать, Dem_max.]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080704</guid>
        <pubDate>Sun, 19 Feb 2012 15:34:56 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080704</link>
        <description><![CDATA[Dem_max: <div class='tag-quote'><span class='tag-quote-prefix'>Цитата</span> <div class='quote '>Смешений? Нет никаких смешений</div></div><br>
Если нет, тогда убери из исходников это <strong class='tag-b'>#include &lt;tchar.h&gt;</strong> так как у тебя только юникод используется.]]></description>
        <author>Dem_max</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080693</guid>
        <pubDate>Sun, 19 Feb 2012 14:45:49 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080693</link>
        <description><![CDATA[neokoder: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=351424&view=findpost&p=3080606'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>B.V. &#064; <time class="tag-quote__quoted-time" datetime="2012-02-19T10:57:01+00:00">19.02.12, 10:57</time></span><div class='quote '>А вот здесь уже слишком много смешений wcs* и _t*-функций. neokoder, можешь привести их все к одному виду?</div></div><br>
Смешений? Нет никаких <em class='tag-i'>смешений</em>, <strong class='tag-b'>B.V.</strong>, здесь всё используется так как надо. Изначально я и сделал так как ты запрашиваешь, но при выключении юникода функции не будут работать, поскольку в реестре все бинарные данные хранятся в юникоде(по крайней мере у меня на Win7, но думаю что в XP таже). Именно поэтому для работы со строкой реестра можно ипользовть только <strong class='tag-b'>WCHAR</strong>. Всё остальное универсально, настроено на работу как с Юникодом так и без него. Можешь попробовать заменить:<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">#define UNICODE</div><div class="code_line">#define _UNICODE</div></ol></div></div></div></div><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">#undef UNICODE</div><div class="code_line">#undef _UNICODE</div></ol></div></div></div></div><br>
<br>
Всё будет работать без проблем.]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080606</guid>
        <pubDate>Sun, 19 Feb 2012 10:57:01 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080606</link>
        <description><![CDATA[B.V.: А вот здесь уже слишком много смешений wcs* и _t*-функций. neokoder, можешь привести их все к одному виду?]]></description>
        <author>B.V.</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080563</guid>
        <pubDate>Sun, 19 Feb 2012 07:25:51 +0000</pubDate>
        <title>Получить инфо о серийном номере, производителе и названии USB Storage Device</title>
        <link>https://forum.sources.ru/index.php?showtopic=351424&amp;view=findpost&amp;p=3080563</link>
        <description><![CDATA[neokoder: <strong class='tag-b'>Получить инфо о серийном номере, производителе и названии USB Storage Device.</strong><br>
Если тестируемый диск является съёмным диском USB Storage Device(флешка, телефон, mp3-плеер и т.д.) функция PrintFlashDriveInfo печатает название производителя устройства, название продукта и серийный номер устройства. Если диск не является USB Storage Device, то выводится об этом сообщение. Функция работает с полным контролем ошибок.<br>
<br>
При необходимости получения выходных параметров(серийный номер, вендор, название) в качестве переменных вместо печати, функция легко переделывается:  можно ввести дополнительный выходной параметр-структуру из 3-х строк и их размеров и заполнять её вместо печати.<br>
<br>
<em class='tag-i'>Примечание: при получении инфо о USB-устройстве таким способом, <span class='tag-u'>иногда</span> внешний жесткий диск также может определиться как съёмное USB-устройство. В этом случае можно ввести доп. проверку того <a class='tag-url' href='http://forum.sources.ru/index.php?showtopic=351430' target='_blank'>является ли диск съёмным USB Storage Device</a> (1 Способ по ссылке)</em><br>
<br>
<strong class='tag-b'>PrintFlashDriveInfo</strong><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">WCHAR* GetElem(WCHAR *ptr,WCHAR delim,WCHAR *buf)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; WCHAR *ptr1=NULL;</div><div class="code_line">&nbsp;&nbsp; ptr1=wcschr(ptr,delim);</div><div class="code_line">&nbsp;&nbsp; if (ptr1)</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wcsncpy(buf,ptr,(int)(ptr1-ptr));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[(int)(ptr1-ptr)]=0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return (ptr1+1);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wcscpy(buf,ptr);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return NULL;</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">//Входные данные:</div><div class="code_line">//IN drive_letter - буква диска</div><div class="code_line">void PrintFlashDriveInfo(WCHAR drive_letter)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; HKEY hk=NULL;</div><div class="code_line">&nbsp;&nbsp; LONG Ret=0;</div><div class="code_line">&nbsp;&nbsp; HANDLE hdrive=INVALID_HANDLE_VALUE;</div><div class="code_line">&nbsp;&nbsp; DWORD data_size,dtype;</div><div class="code_line">&nbsp;&nbsp; WCHAR *data=NULL,*buf1=NULL,*buf2=NULL;</div><div class="code_line">&nbsp;&nbsp; WCHAR *ptr1_1=NULL,*ptr1_2=NULL,*ptr2_1=NULL,*ptr2_2=NULL;</div><div class="code_line">&nbsp;&nbsp; WCHAR dos_link[50];</div><div class="code_line">&nbsp;&nbsp; WCHAR drive_name2[20];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; __try</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;//проверяем существует ли диск в системе</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wsprintf(drive_name2,L&quot;\\.\%c:&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;hdrive = CreateFileW(drive_name2,0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (hdrive==INVALID_HANDLE_VALUE)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка CreateFile: %u\n\n&quot;,GetLastError());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; __leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;CloseHandle(hdrive);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,L&quot;SYSTEM\MountedDevices&quot;,0,KEY_READ,&amp;hk);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (Ret!=ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegOpenKeyEx: %u\n\n&quot;,Ret);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; __leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wsprintf(dos_link,L&quot;\DosDevices\%c:&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Ret=RegQueryValueExW(hk,dos_link,NULL,&amp;dtype,NULL,&amp;data_size);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (Ret==ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; data=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf1=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf2=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if (data==NULL||buf1==NULL||buf2==NULL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка malloc.\n\n&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; memset(data,0,data_size+2);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Ret=RegQueryValueExW(hk,dos_link,NULL,&amp;dtype,(LPBYTE)data,&amp;data_size);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if (Ret!=ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegQueryValueEx: %u\n\n&quot;,Ret);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if(wcsstr(data,L&quot;USBSTOR&quot;)!=NULL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Данные флеш-диска %c:\n&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=GetElem(data,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (ptr1_1)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_2=GetElem(ptr1_1,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=buf1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr2_2=GetElem(ptr1_1,L&#39;&amp;&#39;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wcsstr(buf2,L&quot;Ven_&quot;))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Производитель: %s\n&quot;,buf2+4);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if (wcsstr(buf2,L&quot;Prod_&quot;))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Название продукта: %s\n&quot;,buf2+5);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=ptr2_2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (ptr2_2);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=GetElem(ptr1_2,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=buf1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr2_2=GetElem(ptr1_1,L&#39;&amp;&#39;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wcslen(buf2)&#62;3)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Серийный номер: %s\n&quot;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=ptr2_2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (ptr2_2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }//if USBSTOR</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Диск %c: НЕ является флешкой\n&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegQueryValueEx: %u\n&quot;,Ret);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wprintf(L&quot;\n&quot;);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;&nbsp; __finally</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (data!=NULL) free(data);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (buf1!=NULL) free(buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (buf2!=NULL) free(buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (hk!=NULL) RegCloseKey(hk);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
<strong class='tag-b'>Использование</strong><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; PrintFlashDriveInfo(_T(&#39;G&#39;));</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(_T(&#39;C&#39;));</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(_T(&#39;H&#39;));</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(_T(&#39;I&#39;));</div></ol></div></div></div></div><br>
<br>
<br>
<strong class='tag-b'>Полный исходный код</strong><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">#define UNICODE</div><div class="code_line">#define _UNICODE</div><div class="code_line">#include &#60;windows.h&#62;</div><div class="code_line">#include &#60;stdio.h&#62;</div><div class="code_line">#include &#60;conio.h&#62;</div><div class="code_line">#include &#60;locale.h&#62;</div><div class="code_line">#include &#60;WinIoCtl.h&#62;</div><div class="code_line">&nbsp;</div><div class="code_line">WCHAR* GetElem(WCHAR *ptr,WCHAR delim,WCHAR *buf)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; WCHAR *ptr1=NULL;</div><div class="code_line">&nbsp;&nbsp; ptr1=wcschr(ptr,delim);</div><div class="code_line">&nbsp;&nbsp; if (ptr1)</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wcsncpy(buf,ptr,(int)(ptr1-ptr));</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;buf[(int)(ptr1-ptr)]=0;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return (ptr1+1);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;&nbsp; else</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wcscpy(buf,ptr);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;return NULL;</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">//Входные данные:</div><div class="code_line">//IN drive_letter - буква диска</div><div class="code_line">void PrintFlashDriveInfo(WCHAR drive_letter)</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; HKEY hk=NULL;</div><div class="code_line">&nbsp;&nbsp; LONG Ret=0;</div><div class="code_line">&nbsp;&nbsp; HANDLE hdrive=INVALID_HANDLE_VALUE;</div><div class="code_line">&nbsp;&nbsp; DWORD data_size,dtype;</div><div class="code_line">&nbsp;&nbsp; WCHAR *data=NULL,*buf1=NULL,*buf2=NULL;</div><div class="code_line">&nbsp;&nbsp; WCHAR *ptr1_1=NULL,*ptr1_2=NULL,*ptr2_1=NULL,*ptr2_2=NULL;</div><div class="code_line">&nbsp;&nbsp; WCHAR dos_link[50];</div><div class="code_line">&nbsp;&nbsp; WCHAR drive_name2[20];</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; __try</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;//проверяем существует ли диск в системе</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wsprintf(drive_name2,L&quot;\\.\%c:&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;hdrive = CreateFileW(drive_name2,0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (hdrive==INVALID_HANDLE_VALUE)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка CreateFile: %u\n\n&quot;,GetLastError());</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; __leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;CloseHandle(hdrive);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE,L&quot;SYSTEM\MountedDevices&quot;,0,KEY_READ,&amp;hk);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (Ret!=ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegOpenKeyEx: %u\n\n&quot;,Ret);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; __leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wsprintf(dos_link,L&quot;\DosDevices\%c:&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Ret=RegQueryValueExW(hk,dos_link,NULL,&amp;dtype,NULL,&amp;data_size);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (Ret==ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; data=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf1=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; buf2=(WCHAR *)malloc(data_size+2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if (data==NULL||buf1==NULL||buf2==NULL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка malloc.\n\n&quot;);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; memset(data,0,data_size+2);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; Ret=RegQueryValueExW(hk,dos_link,NULL,&amp;dtype,(LPBYTE)data,&amp;data_size);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if (Ret!=ERROR_SUCCESS)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegQueryValueEx: %u\n\n&quot;,Ret);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;__leave;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; if(wcsstr(data,L&quot;USBSTOR&quot;)!=NULL)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Данные флеш-диска %c:\n&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=GetElem(data,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (ptr1_1)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_2=GetElem(ptr1_1,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=buf1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr2_2=GetElem(ptr1_1,L&#39;&amp;&#39;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wcsstr(buf2,L&quot;Ven_&quot;))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Производитель: %s\n&quot;,buf2+4);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else if (wcsstr(buf2,L&quot;Prod_&quot;))</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Название продукта: %s\n&quot;,buf2+5);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=ptr2_2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (ptr2_2);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=GetElem(ptr1_2,L&#39;#&#39;,buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptr1_1=buf1;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; do</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr2_2=GetElem(ptr1_1,L&#39;&amp;&#39;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (wcslen(buf2)&#62;3)</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Серийный номер: %s\n&quot;,buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ptr1_1=ptr2_2;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } while (ptr2_2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; }//if USBSTOR</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wprintf(L&quot;Диск %c: НЕ является флешкой\n&quot;,drive_letter);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;}</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; wprintf(L&quot;Ошибка PrintFlashDriveInfo: Ошибка RegQueryValueEx: %u\n&quot;,Ret);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;wprintf(L&quot;\n&quot;);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">&nbsp;&nbsp; __finally</div><div class="code_line">&nbsp;&nbsp; {</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (data!=NULL) free(data);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (buf1!=NULL) free(buf1);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (buf2!=NULL) free(buf2);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;if (hk!=NULL) RegCloseKey(hk);</div><div class="code_line">&nbsp;&nbsp; }</div><div class="code_line">}</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;</div><div class="code_line">int wmain(int argc, WCHAR* argv[])</div><div class="code_line">{</div><div class="code_line">&nbsp;&nbsp; setlocale(LC_ALL,&quot;Russian&quot;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;H&#39;);</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;G&#39;);</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;C&#39;);</div><div class="code_line">&nbsp;&nbsp; PrintFlashDriveInfo(L&#39;Я&#39;);</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; wprintf(L&quot;Нажмите любую клавишу...&quot;);</div><div class="code_line">&nbsp;&nbsp; _getch();</div><div class="code_line">&nbsp;&nbsp; return 0;</div><div class="code_line">}</div></ol></div></div></div></div><br>
<br>
p.s. учитывая &quot;просьбы&quot; :) код передалан из универсального(работающего как с UNICODE так и с обычной 8-ми битовой ANSI-строкой) в код работающий только с UNICODE.]]></description>
        <author>neokoder</author>
        <category>C/C++: Системное программирование и WinAPI</category>
      </item>
	
      </channel>
      </rss>
	