<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GSaraiva&#039;s Projects &#187; Usefull Function</title>
	<atom:link href="http://projects.pro.br/gsaraiva/tag/usefull-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://projects.pro.br/gsaraiva</link>
	<description>Step by step</description>
	<lastBuildDate>Tue, 01 Sep 2009 13:14:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Delphi: Utils :: AppRunningCount</title>
		<link>http://projects.pro.br/gsaraiva/2009/07/delphi-utils-apprunningcount/</link>
		<comments>http://projects.pro.br/gsaraiva/2009/07/delphi-utils-apprunningcount/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 20:13:38 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[AppRunningCount]]></category>
		<category><![CDATA[CreateToolhelp32Snapshot]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Process32First]]></category>
		<category><![CDATA[Process32Next]]></category>
		<category><![CDATA[TH32CS_SNAPPROCESS]]></category>
		<category><![CDATA[TProcessEntry32]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://projects.pro.br/gsaraiva/?p=470</guid>
		<description><![CDATA[Folks,
For everybody thats need to limit the instance number of your application:
uses SysUtils, TLHelp32;&#160;function AppRunningCount&#40;const AExeName: string&#41;: integer;var&#160;&#160;hSnap: THandle;&#160;&#160;p32: TProcessEntry32;begin&#160;&#160;Result := 0;&#160;&#160;hSnap := CreateToolHelp32SnapShot&#40;TH32CS_SNAPPROCESS, 0&#41;;&#160;&#160;p32.dwSize := Sizeof&#40;TProcessEntry32&#41;;&#160;&#160;Process32First&#40;hSnap, p32&#41;;&#160;&#160;repeat&#160;&#160;&#160;&#160;if SameText&#40;AExeName, ExtractFileName&#40;p32.szExeFile&#41;&#41; then&#160;&#160;&#160;&#160;&#160;&#160;inc&#40;Result&#41;;&#160;&#160;until not Process32Next&#40;hSnap, p32&#41;;&#160;&#160;CloseHandle&#40;hSnap&#41;;end;
Use:
// On DPR// Limit to 1 instancebegin &#160;&#160;if AppRunningCount&#40;ExtractFileName&#40;ParamStr&#40;0&#41;&#41;&#41; = 1 then&#160;&#160;begin&#160;&#160;// Application codes&#160;&#160;end;end.
Explaining more about this approach:
In a situation of multiples [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>For everybody thats need to limit the instance number of your application:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> SysUtils<span style="color: #000066;">,</span> TLHelp32<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> AppRunningCount<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">const</span> AExeName<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;hSnap<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">THandle</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;p32<span style="color: #000066;">:</span> TProcessEntry32<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;hSnap <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateToolHelp32SnapShot<span style="color: #000066;">&#40;</span>TH32CS_SNAPPROCESS<span style="color: #000066;">,</span> 0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;p32<span style="color: #000066;">.</span><span style="color: #006600;">dwSize</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">Sizeof</span><span style="color: #000066;">&#40;</span>TProcessEntry32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Process32First<span style="color: #000066;">&#40;</span>hSnap<span style="color: #000066;">,</span> p32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">repeat</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">SameText</span><span style="color: #000066;">&#40;</span>AExeName<span style="color: #000066;">,</span> <span style="color: #000066;">ExtractFileName</span><span style="color: #000066;">&#40;</span>p32<span style="color: #000066;">.</span><span style="color: #006600;">szExeFile</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">inc</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">until</span> <span style="color: #000000; font-weight: bold;">not</span> Process32Next<span style="color: #000066;">&#40;</span>hSnap<span style="color: #000066;">,</span> p32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;CloseHandle<span style="color: #000066;">&#40;</span>hSnap<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Use:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #808080; font-style: italic;">// On DPR</span></li><li><span style="color: #808080; font-style: italic;">// Limit to 1 instance</span></li><li><span style="color: #000000; font-weight: bold;">begin</span> </li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> AppRunningCount<span style="color: #000066;">&#40;</span><span style="color: #000066;">ExtractFileName</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span>0<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> 1 <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">// Application codes</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">.</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Explaining more about this approach:<br />
In a situation of multiples logons at the same machine the Mutex cannot provide a correctly singleton structure because the mutex handle still only under the local scope of the user. So the way to control the instance number is counting the number of times the process appear on the process list of the machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2009/07/delphi-utils-apprunningcount/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: WalkOnHandles</title>
		<link>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-walkonhandles/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-walkonhandles/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 01:36:31 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[CreateToolhelp32Snapshot]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetNextWindow]]></category>
		<category><![CDATA[GetTopWindow]]></category>
		<category><![CDATA[GetWindowThreadProcessID]]></category>
		<category><![CDATA[Usefull Function]]></category>
		<category><![CDATA[WalkOnHandlesOfExe]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=138</guid>
		<description><![CDATA[Folks,
A light for everybody. First of all, I&#8217;ll use two other usefull functions I posted on this site:
GetHwndClass
GetHwndText
And now the magic:
uses Windows, TLHelp32;&#160;type&#160;&#160;TWalkOnHandlesCallback = function&#40;AHwnd, AParentHWnd: HWND;&#160;&#160;&#160;&#160;AClass, AText: string; AFlag: Integer&#41;: boolean of object;&#160;function WalkOnHandles&#40;AParent: HWND; AFlag: integer;&#160;&#160;ACallback: TWalkOnHandlesCallback&#41;: Integer;var&#160;&#160;CurrHWnd: HWND;begin&#160;&#160;Result := 0;&#160;&#160;CurrHWnd := GetTopWindow&#40;AParent&#41;;&#160;&#160;while CurrHWnd &#60;&#62; 0 do&#160;&#160;begin&#160;&#160;&#160;&#160;Result := Result + 1;&#160;&#160;&#160;&#160;if Assigned&#40;ACallback&#41; then&#160;&#160;&#160;&#160;&#160;&#160;if [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>A light for everybody. First of all, I&#8217;ll use two other usefull functions I posted on this site:</p>
<li><a href="http://gsaraiva.projects.pro.br/?p=127">GetHwndClass</a></li>
<li><a href="http://gsaraiva.projects.pro.br/?p=125">GetHwndText</a></li>
<p>And now the magic:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> Windows<span style="color: #000066;">,</span> TLHelp32<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;TWalkOnHandlesCallback <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #000066;">&#40;</span>AHwnd<span style="color: #000066;">,</span> AParentHWnd<span style="color: #000066;">:</span> HWND<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;AClass<span style="color: #000066;">,</span> AText<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span> AFlag<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">boolean</span> <span style="color: #000000; font-weight: bold;">of</span> <span style="color: #000000; font-weight: bold;">object</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> WalkOnHandles<span style="color: #000066;">&#40;</span>AParent<span style="color: #000066;">:</span> HWND<span style="color: #000066;">;</span> AFlag<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;ACallback<span style="color: #000066;">:</span> TWalkOnHandlesCallback<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;CurrHWnd<span style="color: #000066;">:</span> HWND<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;CurrHWnd <span style="color: #000066;">:</span><span style="color: #000066;">=</span> GetTopWindow<span style="color: #000066;">&#40;</span>AParent<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">while</span> CurrHWnd &lt;&gt; 0 <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Result <span style="color: #000066;">+</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">Assigned</span><span style="color: #000066;">&#40;</span>ACallback<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">not</span> ACallback<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">,</span> AParent<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetHwndClass<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> GetHwndText<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> AFlag<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">Break</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;CurrHWnd <span style="color: #000066;">:</span><span style="color: #000066;">=</span> GetNextWindow<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">,</span> GW_HWNDNEXT<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> WalkOnHandlesOfExe<span style="color: #000066;">&#40;</span>AExeName<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span> AFlag<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;ACallback<span style="color: #000066;">:</span> TWalkOnHandlesCallback<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;PID<span style="color: #000066;">,</span> CheckPID<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">DWord</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;hSnapShot<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">THandle</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;ProcessEntry<span style="color: #000066;">:</span> TProcessEntry32<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;CurrHWnd<span style="color: #000066;">:</span> HWND<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;PID <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">0</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;hSnapShot <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateToolhelp32Snapshot<span style="color: #000066;">&#40;</span><span style="color: #000066;">&#40;</span>TH32CS_SNAPALL<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> 0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;ProcessEntry<span style="color: #000066;">.</span><span style="color: #006600;">dwSize</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">SizeOf</span><span style="color: #000066;">&#40;</span>TProcessEntry32<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Process32First<span style="color: #000066;">&#40;</span>hSnapShot<span style="color: #000066;">,</span> ProcessEntry<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">repeat</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> ProcessEntry<span style="color: #000066;">.</span><span style="color: #006600;">szExeFile</span> <span style="color: #000066;">=</span> AExeName <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PID <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ProcessEntry<span style="color: #000066;">.</span><span style="color: #006600;">th32ProcessID</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">Break</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">until</span> Process32Next<span style="color: #000066;">&#40;</span>hSnapShot<span style="color: #000066;">,</span> ProcessEntry<span style="color: #000066;">&#41;</span> <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;CloseHandle<span style="color: #000066;">&#40;</span>hSnapShot<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> PID &gt; 0 <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;CurrHWnd <span style="color: #000066;">:</span><span style="color: #000066;">=</span> GetTopWindow<span style="color: #000066;">&#40;</span>GetDesktopWindow<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">while</span> CurrHWnd &lt;&gt; 0 <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Result <span style="color: #000066;">+</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetWindowThreadProcessID<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">,</span> <span style="color: #000066;">@</span>CheckPID<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> CheckPID <span style="color: #000066;">=</span> PID <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000066;">Assigned</span><span style="color: #000066;">&#40;</span>ACallback<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">not</span> ACallback<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">,</span> 0<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetHwndClass<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> GetHwndText<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> AFlag<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">Break</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CurrHWnd <span style="color: #000066;">:</span><span style="color: #000066;">=</span> GetNextWindow<span style="color: #000066;">&#40;</span>CurrHWnd<span style="color: #000066;">,</span> GW_HWNDNEXT<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Now let me explain what this big code do.</p>
<p>This code its only a light, a simple idea, about how you can navigate through the Windows Objects (Handle) from everywhere.</p>
<p>A simple example:</p>
<li>Create a TMemo named mmoLog</li>
<li>Link OnCreate of the Main Form</li>
<li>Create a the callback on the Main Form class</li>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li></li><li>&nbsp;&nbsp;TForm1 <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TForm<span style="color: #000066;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;mmoLog<span style="color: #000066;">:</span> TMemo<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">procedure</span> FormCreate<span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">{ Private declarations }</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">function</span> WalkCall<span style="color: #000066;">&#40;</span>AHwnd<span style="color: #000066;">,</span> AParentHWnd<span style="color: #000066;">:</span> HWND<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AClass<span style="color: #000066;">,</span> AText<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span> AFlag<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--><br />
The rest of the code:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li></li><li><span style="color: #000000; font-weight: bold;">procedure</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">FormCreate</span><span style="color: #000066;">&#40;</span>Sender<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">TObject</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;WalkOnHandlesOfExe<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'delphi32.exe'</span><span style="color: #000066;">,</span> 0<span style="color: #000066;">,</span> WalkCall<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> TForm1<span style="color: #000066;">.</span><span style="color: #006600;">WalkCall</span><span style="color: #000066;">&#40;</span>AHwnd<span style="color: #000066;">,</span> AParentHWnd<span style="color: #000066;">:</span> HWND<span style="color: #000066;">;</span> AClass<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;AText<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span> AFlag<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;mmoLog<span style="color: #000066;">.</span><span style="color: #006600;">Lines</span><span style="color: #000066;">.</span><span style="color: #006600;">Add</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">stringofChar</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">' '</span><span style="color: #000066;">,</span> AFlag<span style="color: #000066;">&#41;</span>&nbsp;&nbsp;<span style="color: #000066;">+</span> <span style="color: #000066;">Format</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'%d: [ %s ] %s'</span><span style="color: #000066;">,</span> <span style="color: #000066;">&#91;</span>AHwnd<span style="color: #000066;">,</span> AClass<span style="color: #000066;">,</span> AText<span style="color: #000066;">&#93;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;WalkOnHandles<span style="color: #000066;">&#40;</span>AHwnd<span style="color: #000066;">,</span> AFlag <span style="color: #000066;">+</span> 2<span style="color: #000066;">,</span> WalkCall<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>This example will list all Windows Objects on the Delphi application and will result a idented log on the mmoLog. </p>
<p>Simple uhm?</p>
<li><strong>WalkOnHandles</strong><br />
Walk on all handles by the Z-order of the specified Parent.
</li>
<li><strong>WalkOnHandlesOfExe</strong><br />
Walk on all handles by the Z-order that have DesktopWindow as parent and the Application as owner.
</li>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-walkonhandles/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: AppSingleton</title>
		<link>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-appsingleton/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-appsingleton/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 23:02:10 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[AppSingleton]]></category>
		<category><![CDATA[CreateMutex]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=135</guid>
		<description><![CDATA[Folks,
This code below implement a singleton structure for the aplication, and that need to be implemented on the DPR file of the project:
uses Windows;&#160;function AppSingleton&#40;ACheckPath: boolean = false&#41;: boolean;var&#160;&#160;s: string;&#160;&#160;i, iLast: Cardinal;begin&#160;&#160;s := ParamStr&#40;0&#41;;&#160;&#160;iLast := 1;&#160;&#160;case Integer&#40;ACheckPath&#41; of&#160;&#160;&#160;&#160;0: for i := 1 to Length&#40;s&#41; do if s&#91;i&#93; = '\' then iLast := i;&#160;&#160;&#160;&#160;1: for i [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>This code below implement a singleton structure for the aplication, and that need to be implemented on the DPR file of the project:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> Windows<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> AppSingleton<span style="color: #000066;">&#40;</span>ACheckPath<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">boolean</span> <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">boolean</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;s<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;i<span style="color: #000066;">,</span> iLast<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Cardinal</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;s <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">ParamStr</span><span style="color: #000066;">&#40;</span>0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;iLast <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">1</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">&#40;</span>ACheckPath<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">of</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;0<span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000066;">:</span><span style="color: #000066;">=</span> 1 <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>s<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">if</span> s<span style="color: #000066;">&#91;</span>i<span style="color: #000066;">&#93;</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">'\'</span> <span style="color: #000000; font-weight: bold;">then</span> iLast <span style="color: #000066;">:</span><span style="color: #000066;">=</span> i<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;1<span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000066;">:</span><span style="color: #000066;">=</span> 1 <span style="color: #000000; font-weight: bold;">to</span> <span style="color: #000066;">Length</span><span style="color: #000066;">&#40;</span>s<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #000000; font-weight: bold;">if</span> s<span style="color: #000066;">&#91;</span>i<span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000066;">&#91;</span><span style="color: #ff0000;">':'</span><span style="color: #000066;">,</span><span style="color: #ff0000;">'\'</span><span style="color: #000066;">,</span><span style="color: #ff0000;">'.'</span><span style="color: #000066;">,</span><span style="color: #ff0000;">' '</span><span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">then</span> s<span style="color: #000066;">&#91;</span>i<span style="color: #000066;">&#93;</span> <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #ff0000;">'_'</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">&#40;</span>CreateMutex<span style="color: #000066;">&#40;</span><span style="color: #000000; font-weight: bold;">nil</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #000066;">,</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">Cardinal</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">@</span>s<span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #000066;">&#40;</span>iLast <span style="color: #000066;">-</span> 1<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span> &lt;&gt; 0<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">and</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">&#40;</span><span style="color: #000066;">GetLastError</span> <span style="color: #000066;">=</span> 0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>I use the <a href="http://gsaraiva.projects.pro.br/?p=30"><strong>CreateMutex</strong></a> API that works as a semaphore, if open, the application is unique, if closed the application is already running.</p>
<p>I wrote a condition to check the full path of the application for the Mutex call, so if you want to check the full path use the funciotn with param as True, the default is False and the check will be only on the application exe name.</p>
<p>A little detail about checking the functionality of this function:<br />
Under debug mode the checkout on full path mode will fail and more then one application can be raised. This problem is because the relationship of the application with other program, so the CreateMutex API understand the Process ID is diferent from others.</p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/07/delphi-utils-appsingleton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: GetShellFolder</title>
		<link>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-getusershellfolder/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-getusershellfolder/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:43:56 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Administrative Tools]]></category>
		<category><![CDATA[AppData]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[CD Burning]]></category>
		<category><![CDATA[Cookies]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Favorites]]></category>
		<category><![CDATA[Fonts]]></category>
		<category><![CDATA[GetUserShellFolder]]></category>
		<category><![CDATA[History]]></category>
		<category><![CDATA[HKEY_CURRENT_USER]]></category>
		<category><![CDATA[Local AppData]]></category>
		<category><![CDATA[Local Settings]]></category>
		<category><![CDATA[My Music]]></category>
		<category><![CDATA[My Pictures]]></category>
		<category><![CDATA[My Video]]></category>
		<category><![CDATA[NetHood]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[PrintHood]]></category>
		<category><![CDATA[Programs]]></category>
		<category><![CDATA[Recent]]></category>
		<category><![CDATA[SendTo]]></category>
		<category><![CDATA[Shell Folders]]></category>
		<category><![CDATA[Start Menu]]></category>
		<category><![CDATA[Startup]]></category>
		<category><![CDATA[Templates]]></category>
		<category><![CDATA[TRegistry]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=134</guid>
		<description><![CDATA[Folks,
Get some Shell Folder from Current User or All User ( System ):
uses Registry;&#160;type&#160;&#160;TShellFolderType = &#40;&#160;&#160;&#160;&#160;// User&#160;&#160;&#160;&#160;sftAppData, sftCookies, sftDesktop, sftFavorites,&#160;&#160;&#160;&#160;sftNetHood, sftPersonal, sftPrintHood, sftRecent, sftSendTo, sftStartMenu,&#160;&#160;&#160;&#160;sftTemplates, sftPrograms, sftStartup, sftLocalSettings, sftLocalAppData,&#160;&#160;&#160;&#160;sftCache, sftHistory, sftMyPictures, sftFonts, sftMyMusic, sftCDBurning,&#160;&#160;&#160;&#160;sftMyVideo, sftAdminTools,&#160;&#160;&#160;&#160;// System&#160;&#160;&#160;&#160;sftCommonAppData, sftCommonPrograms, sftCommonDocuments, sftCommonDesktop,&#160;&#160;&#160;&#160;sftCommonStartMenu, sftCommonPictures, sftCommonMusic, sftCommonVideo,&#160;&#160;&#160;&#160;sftCommonFavorites, sftCommonStartup, sftCommonTemplates,&#160;&#160;&#160;&#160;sftCommonAdminTools, sftCommonPersonal&#41;;&#160;&#160;function GetShellFolder&#40;AShellFolderType: TShellFolderType&#41;: string;begin&#160;&#160;with TRegistry.Create do&#160;&#160;begin&#160;&#160;&#160;&#160;if AShellFolderType &#60;= sftAdminTools then&#160;&#160;&#160;&#160;&#160;&#160;RootKey := [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Get some Shell Folder from Current User or All User ( System ):<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> Registry<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">type</span></li><li>&nbsp;&nbsp;TShellFolderType <span style="color: #000066;">=</span> <span style="color: #000066;">&#40;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">// User</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftAppData<span style="color: #000066;">,</span> sftCookies<span style="color: #000066;">,</span> sftDesktop<span style="color: #000066;">,</span> sftFavorites<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftNetHood<span style="color: #000066;">,</span> sftPersonal<span style="color: #000066;">,</span> sftPrintHood<span style="color: #000066;">,</span> sftRecent<span style="color: #000066;">,</span> sftSendTo<span style="color: #000066;">,</span> sftStartMenu<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftTemplates<span style="color: #000066;">,</span> sftPrograms<span style="color: #000066;">,</span> sftStartup<span style="color: #000066;">,</span> sftLocalSettings<span style="color: #000066;">,</span> sftLocalAppData<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftCache<span style="color: #000066;">,</span> sftHistory<span style="color: #000066;">,</span> sftMyPictures<span style="color: #000066;">,</span> sftFonts<span style="color: #000066;">,</span> sftMyMusic<span style="color: #000066;">,</span> sftCDBurning<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftMyVideo<span style="color: #000066;">,</span> sftAdminTools<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">// System</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftCommonAppData<span style="color: #000066;">,</span> sftCommonPrograms<span style="color: #000066;">,</span> sftCommonDocuments<span style="color: #000066;">,</span> sftCommonDesktop<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftCommonStartMenu<span style="color: #000066;">,</span> sftCommonPictures<span style="color: #000066;">,</span> sftCommonMusic<span style="color: #000066;">,</span> sftCommonVideo<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftCommonFavorites<span style="color: #000066;">,</span> sftCommonStartup<span style="color: #000066;">,</span> sftCommonTemplates<span style="color: #000066;">,</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;sftCommonAdminTools<span style="color: #000066;">,</span> sftCommonPersonal<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> GetShellFolder<span style="color: #000066;">&#40;</span>AShellFolderType<span style="color: #000066;">:</span> TShellFolderType<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">with</span> TRegistry<span style="color: #000066;">.</span><span style="color: #006600;">Create</span> <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> AShellFolderType &lt;<span style="color: #000066;">=</span> sftAdminTools <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RootKey <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HKEY_CURRENT_USER</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">else</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RootKey <span style="color: #000066;">:</span><span style="color: #000066;">=</span> HKEY_LOCAL_MACHINE<span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;OpenKey<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'</span><span style="color: #000066;">,</span> <span style="color: #000000; font-weight: bold;">True</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">case</span> AShellFolderType <span style="color: #000000; font-weight: bold;">of</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftAppData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'AppData'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCookies&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Cookies'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftDesktop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Desktop'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftFavorites&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Favorites'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftNetHood&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'NetHood'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftPersonal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Personal'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftPrintHood&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'PrintHood'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftRecent&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Recent'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftSendTo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'SendTo'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftStartMenu&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Start Menu'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftTemplates&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Templates'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftPrograms&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Programs'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftStartup&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Startup'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftLocalSettings <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Local Settings'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftLocalAppData&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Local AppData'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCache&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Cache'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftHistory&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'History'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftMyPictures&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'My Pictures'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftFonts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Fonts'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftMyMusic&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'My Music'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCDBurning&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'CD Burning'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftMyVideo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'My Video'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftAdminTools&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Administrative Tools'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #808080; font-style: italic;">// System</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonAppData&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common AppData'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonPrograms&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Programs'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonDocuments&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Documents'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonDesktop&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Desktop'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonStartMenu&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Start Menu'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonPictures&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'CommonPictures'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonMusic&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'CommonMusic'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonVideo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'CommonVideo'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonFavorites&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Favorites'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonStartup&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Startup'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonTemplates&nbsp;&nbsp;<span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Templates'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonAdminTools <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Common Administrative Tools'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sftCommonPersonal&nbsp;&nbsp; <span style="color: #000066;">:</span> Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> ReadString<span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Personal'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-getusershellfolder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: WinSystem32Path</title>
		<link>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-winsystem32path/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-winsystem32path/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:26:28 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetSystemDirectory]]></category>
		<category><![CDATA[Usefull Function]]></category>
		<category><![CDATA[WinSystem32Path]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=132</guid>
		<description><![CDATA[Folks,
Get Windows&#8217;s System32 Directory as Path ( \ at end)
var&#160;&#160;WinSystem32PathStr: string = '';&#160;function WinSystem32Path: string;begin&#160;&#160;if WinSystem32PathStr = '' then&#160;&#160;begin&#160;&#160;&#160;&#160;SetLength&#40;Result, MAX_PATH&#41;;&#160;&#160;&#160;&#160;SetLength&#40;Result, GetSystemDirectory&#40;PChar&#40;Result&#41;, MAX_PATH&#41;&#41;;&#160;&#160;&#160;&#160;WinSystem32PathStr := Result + '\';&#160;&#160;end;&#160;&#160;Result := WinSystem32PathStr;end; 
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Get Windows&#8217;s System32 Directory as Path ( \ at end)<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;WinSystem32PathStr<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> WinSystem32Path<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> WinSystem32PathStr <span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> MAX_PATH<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> GetSystemDirectory<span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> MAX_PATH<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;WinSystem32PathStr <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Result <span style="color: #000066;">+</span> <span style="color: #ff0000;">'\'</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> WinSystem32PathStr<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--> </p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-winsystem32path/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: WindowsPath</title>
		<link>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-windowspath/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-windowspath/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:23:26 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetWindowsDirectory]]></category>
		<category><![CDATA[Usefull Function]]></category>
		<category><![CDATA[WindowsPath]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=130</guid>
		<description><![CDATA[Folks,
Get the Windows Directory as Path ( \ at end ):
var&#160;&#160;WindowsPathStr: string = '';&#160;function WindowsPath: string;begin&#160;&#160;if WindowsPathStr = '' then&#160;&#160;begin&#160;&#160;&#160;&#160;SetLength&#40;Result, MAX_PATH&#41;;&#160;&#160;&#160;&#160;SetLength&#40;Result, GetWindowsDirectory&#40;PChar&#40;Result&#41;, MAX_PATH&#41;&#41;;&#160;&#160;&#160;&#160;WindowsPathStr := Result + '\';&#160;&#160;end;&#160;&#160;Result := WindowsPathStr;end;
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Get the Windows Directory as Path ( \ at end ):<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;WindowsPathStr<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span> <span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span><span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> WindowsPath<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">if</span> WindowsPathStr <span style="color: #000066;">=</span> <span style="color: #ff0000;">''</span> <span style="color: #000000; font-weight: bold;">then</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> MAX_PATH<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> GetWindowsDirectory<span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> MAX_PATH<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;WindowsPathStr <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Result <span style="color: #000066;">+</span> <span style="color: #ff0000;">'\'</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> WindowsPathStr<span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-windowspath/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: GetShortcutCmd</title>
		<link>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-getshortcutcmd/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-getshortcutcmd/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:10:31 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[CLSID_ShellLink]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetShortcutCmd]]></category>
		<category><![CDATA[IPersistFile]]></category>
		<category><![CDATA[IShellLink]]></category>
		<category><![CDATA[SLGP_UNCPRIORITY]]></category>
		<category><![CDATA[TWin32FindData]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=128</guid>
		<description><![CDATA[Folks,
Get the program and command line of a shortcurt file (.LNK)
uses ActiveX, ComObj, ShlObj;&#160;function GetShortcutCmd&#40;AShortcutPath: string&#41;: string;var&#160;&#160;ShellLink: IUnknown;&#160;&#160;Win32Data: TWin32FindData;&#160;&#160;Buff: array &#91;0..MAX_PATH*2&#93; of Char;begin&#160;&#160;ShellLink := CreateComObject&#40;CLSID_ShellLink&#41;;&#160;&#160;with &#40;ShellLink as IShellLink&#41;, &#40;ShellLink as IPersistFile&#41; do&#160;&#160;begin&#160;&#160;&#160;&#160;Load&#40;PWChar&#40;WideString&#40;AShortcutPath&#41;&#41;, 0&#41;;&#160;&#160;&#160;&#160;GetPath&#40;@Buff&#91;0&#93;, MAX_PATH, Win32Data, SLGP_UNCPRIORITY&#41;;&#160;&#160;&#160;&#160;GetArguments&#40;@Buff&#91;MAX_PATH&#93;, MAX_PATH&#41;;&#160;&#160;&#160;&#160;Result := Trim&#40;PChar&#40;@Buff&#41; + ' ' + PChar&#40;@Buff&#91;MAX_PATH&#93;&#41;&#41;;&#160;&#160;end;end;
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Get the program and command line of a shortcurt file (.LNK)<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> ActiveX<span style="color: #000066;">,</span> ComObj<span style="color: #000066;">,</span> ShlObj<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> GetShortcutCmd<span style="color: #000066;">&#40;</span>AShortcutPath<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;ShellLink<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">IUnknown</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Win32Data<span style="color: #000066;">:</span> TWin32FindData<span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Buff<span style="color: #000066;">:</span> <span style="color: #000000; font-weight: bold;">array</span> <span style="color: #000066;">&#91;</span>0<span style="color: #000066;">..</span><span style="color: #006600;">MAX_PATH</span><span style="color: #000066;">*</span>2<span style="color: #000066;">&#93;</span> <span style="color: #000000; font-weight: bold;">of</span> <span style="color: #000066; font-weight: bold;">Char</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;ShellLink <span style="color: #000066;">:</span><span style="color: #000066;">=</span> CreateComObject<span style="color: #000066;">&#40;</span>CLSID_ShellLink<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">with</span> <span style="color: #000066;">&#40;</span>ShellLink <span style="color: #000000; font-weight: bold;">as</span> IShellLink<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> <span style="color: #000066;">&#40;</span>ShellLink <span style="color: #000000; font-weight: bold;">as</span> IPersistFile<span style="color: #000066;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Load<span style="color: #000066;">&#40;</span>PWChar<span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">WideString</span><span style="color: #000066;">&#40;</span>AShortcutPath<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> 0<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;GetPath<span style="color: #000066;">&#40;</span><span style="color: #000066;">@</span>Buff<span style="color: #000066;">&#91;</span>0<span style="color: #000066;">&#93;</span><span style="color: #000066;">,</span> MAX_PATH<span style="color: #000066;">,</span> Win32Data<span style="color: #000066;">,</span> SLGP_UNCPRIORITY<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;GetArguments<span style="color: #000066;">&#40;</span><span style="color: #000066;">@</span>Buff<span style="color: #000066;">&#91;</span>MAX_PATH<span style="color: #000066;">&#93;</span><span style="color: #000066;">,</span> MAX_PATH<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">Trim</span><span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">@</span>Buff<span style="color: #000066;">&#41;</span> <span style="color: #000066;">+</span> <span style="color: #ff0000;">' '</span> <span style="color: #000066;">+</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span><span style="color: #000066;">@</span>Buff<span style="color: #000066;">&#91;</span>MAX_PATH<span style="color: #000066;">&#93;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-getshortcutcmd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: GetHwndClass</title>
		<link>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-gethwndclass/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-gethwndclass/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:03:50 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetClassName]]></category>
		<category><![CDATA[GetHwndClass]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=127</guid>
		<description><![CDATA[Folks,
Get the Class Name of the Window Object ( Handle )
uses Windows;&#160;function GetHwndClass&#40;AHandle: HWND&#41;: string;begin&#160;&#160;SetLength&#40;Result, 255&#41;;&#160;&#160;GetClassName&#40;AHandle, PChar&#40;Result&#41;, 255&#41;;&#160;&#160;Result := StrPas&#40;PChar&#40;Result&#41;&#41;;end;
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>Get the Class Name of the Window Object ( Handle )<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> Windows<span style="color: #000066;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> GetHwndClass<span style="color: #000066;">&#40;</span>AHandle<span style="color: #000066;">:</span> HWND<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> 255<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;GetClassName<span style="color: #000066;">&#40;</span>AHandle<span style="color: #000066;">,</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> 255<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #000066;">StrPas</span><span style="color: #000066;">&#40;</span><span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-gethwndclass/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delphi: Utils :: GetHwndText</title>
		<link>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-gethwndtext/</link>
		<comments>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-gethwndtext/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 01:01:28 +0000</pubDate>
		<dc:creator>Gilberto Saraiva</dc:creator>
				<category><![CDATA[articles]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[GetHwndText]]></category>
		<category><![CDATA[GetWindowText]]></category>
		<category><![CDATA[GetWindowTextLength]]></category>
		<category><![CDATA[Usefull Function]]></category>

		<guid isPermaLink="false">http://gsaraiva.projects.pro.br/?p=125</guid>
		<description><![CDATA[Folks,
The first of a serie of usefull functions, that I&#8217;ll provide here.
Get the Text ( Caption ) of a Windows Object ( Handle )
uses Windows;&#160;&#160;function GetHwndText&#40;AHandle: HWND&#41;: string;var&#160;&#160;iLen: integer;begin&#160;&#160;iLen := GetWindowTextLength&#40;AHandle&#41;;&#160;&#160;SetLength&#40;Result, iLen&#41;;&#160;&#160;GetWindowText&#40;AHandle, PChar&#40;Result&#41;, iLen + 1&#41;;end;
]]></description>
			<content:encoded><![CDATA[<p><strong>Folks,</strong></p>
<p>The first of a serie of usefull functions, that I&#8217;ll provide here.</p>
<p>Get the Text ( Caption ) of a Windows Object ( Handle )<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Delphi"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">uses</span> Windows<span style="color: #000066;">;</span></li><li>&nbsp;</li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">function</span> GetHwndText<span style="color: #000066;">&#40;</span>AHandle<span style="color: #000066;">:</span> HWND<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">string</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">var</span></li><li>&nbsp;&nbsp;iLen<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">begin</span></li><li>&nbsp;&nbsp;iLen <span style="color: #000066;">:</span><span style="color: #000066;">=</span> GetWindowTextLength<span style="color: #000066;">&#40;</span>AHandle<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000066;">SetLength</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">,</span> iLen<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li>&nbsp;&nbsp;GetWindowText<span style="color: #000066;">&#40;</span>AHandle<span style="color: #000066;">,</span> <span style="color: #000066; font-weight: bold;">PChar</span><span style="color: #000066;">&#40;</span>Result<span style="color: #000066;">&#41;</span><span style="color: #000066;">,</span> iLen <span style="color: #000066;">+</span> 1<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span></li><li><span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
]]></content:encoded>
			<wfw:commentRss>http://projects.pro.br/gsaraiva/2008/06/delphi-utils-gethwndtext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
