<?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>SnippetWare.com &#187; Shell &amp; Applications</title>
	<atom:link href="http://www.snippetware.com/category/vb/shell-applications/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.snippetware.com</link>
	<description>Code snippets library</description>
	<lastBuildDate>Fri, 22 Jan 2010 12:04:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Launch Application (using CreateProcessA API function)</title>
		<link>http://www.snippetware.com/2009/10/11/launch-application-using-createprocessa-api-function/</link>
		<comments>http://www.snippetware.com/2009/10/11/launch-application-using-createprocessa-api-function/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 12:18:38 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Shell & Applications]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=182</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/11/launch-application-using-createprocessa-api-function/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre class="brush: vb">
Public Function StartProcess(CommandLine As String, Optional Hide As Boolean = False) As Long
    Const STARTF_USESHOWWINDOW As Long = &amp;H1
    Const SW_HIDE As Long = 0

    Dim proc As PROCESS_INFORMATION
    Dim Start As STARTUPINFO

    &#039;Initialize the STARTUPINFO structure:
    Start.cb = Len(Start)
    If Hide Then
        Start.dwFlags = STARTF_USESHOWWINDOW
        Start.wShowWindow = SW_HIDE
    End If

    &#039;Start the shelled application:
    CreateProcessA 0&amp;, CommandLine, 0&amp;, 0&amp;, 1&amp;, _
        NORMAL_PRIORITY_CLASS, 0&amp;, 0&amp;, Start, proc

    StartProcess = proc.hProcess
End Function
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/11/launch-application-using-createprocessa-api-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launch Application (with advanced parameters)</title>
		<link>http://www.snippetware.com/2009/10/11/launch-application-with-advanced-parameters/</link>
		<comments>http://www.snippetware.com/2009/10/11/launch-application-with-advanced-parameters/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 12:18:07 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Shell & Applications]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=180</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/11/launch-application-with-advanced-parameters/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre class="brush: vb">
Public Function SyncShell(CommandLine As String, Optional Timeout As Long, _
    Optional WaitForInputIdle As Boolean, Optional Hide As Boolean = False) As Boolean

    Dim hProcess As Long

    Const STARTF_USESHOWWINDOW As Long = &amp;H1
    Const SW_HIDE As Long = 0

    Dim ret As Long
    Dim nMilliseconds As Long

    If Timeout &gt; 0 Then
        nMilliseconds = Timeout
    Else
        nMilliseconds = INFINITE
    End If

    hProcess = StartProcess(CommandLine, Hide)

    If WaitForInputIdle Then
        &#039;Wait for the shelled application to finish setting up its UI:
        ret = InputIdle(hProcess, nMilliseconds)
    Else
        &#039;Wait for the shelled application to terminate:
        ret = WaitForSingleObject(hProcess, nMilliseconds)
    End If

    CloseHandle hProcess

    &#039;Return True if the application finished. Otherwise it timed out or erred.
    SyncShell = (ret = WAIT_OBJECT_0)
End Function
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/11/launch-application-with-advanced-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shell out to a 32-bit application and wait until task completes</title>
		<link>http://www.snippetware.com/2009/10/11/shell-out-to-a-32-bit-application-and-wait-until-task-completes/</link>
		<comments>http://www.snippetware.com/2009/10/11/shell-out-to-a-32-bit-application-and-wait-until-task-completes/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 12:16:56 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Shell & Applications]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=178</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/11/shell-out-to-a-32-bit-application-and-wait-until-task-completes/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre class="brush: vb">
&#039; Declarations

&#039;*** Monitoring a DOS Shell
Private Declare Function OpenProcess Lib &quot;Kernel32&quot; (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib &quot;Kernel32&quot; (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib &quot;Kernel32&quot; (ByVal dwMilliseconds As Long)
Const STILL_ACTIVE = &amp;H103
Const PROCESS_QUERY_INFORMATION = &amp;H400

&#039; Code

Sub Shell32Bit(ByVal JobToDo As String)

         Dim hProcess As Long
         Dim RetVal As Long
         &#039;The next line launches JobToDo as icon,

         &#039;captures process ID
         hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, Shell(JobToDo, 1))

         Do

             &#039;Get the status of the process
             GetExitCodeProcess hProcess, RetVal

             &#039;Sleep command recommended as well as DoEvents
             DoEvents: Sleep 100

         &#039;Loop while the process is active
         Loop While RetVal = STILL_ACTIVE

End Sub
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/11/shell-out-to-a-32-bit-application-and-wait-until-task-completes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lauches an application based on file extension</title>
		<link>http://www.snippetware.com/2009/10/11/lauches-an-application-based-on-file-extension/</link>
		<comments>http://www.snippetware.com/2009/10/11/lauches-an-application-based-on-file-extension/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 12:16:19 +0000</pubDate>
		<dc:creator>Zaur</dc:creator>
				<category><![CDATA[Shell & Applications]]></category>

		<guid isPermaLink="false">http://www.snippetware.com/?p=176</guid>
		<description><![CDATA[<p><a href="http://www.snippetware.com/2009/10/11/lauches-an-application-based-on-file-extension/">Continue</a></p>]]></description>
			<content:encoded><![CDATA[<pre class="brush: vb">
&#039; ----------------------------
&#039; Constants &amp; API Declarations
&#039; ----------------------------

Private Declare Function ShellExecute Lib &quot;shell32.dll&quot; Alias &quot;ShellExecuteA&quot; (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib &quot;user32&quot; Alias &quot;GetDesktopWindow&quot; () As Long

&#039; ----------
&#039; Function
&#039; ----------

Function StartDoc (DocName As String) as long
    Dim Scr_hDC as long

    Scr_hDC = GetDesktopWindow()

    &#039; Change &quot;Open&quot; to &quot;Explore&quot; to bring up file explorer
    StartDoc = ShellExecute(Scr_hDC, &quot;Open&quot;, DocName, &quot;&quot;, &quot;C:\&quot;, 1)
End Function
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.snippetware.com/2009/10/11/lauches-an-application-based-on-file-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

