Re: Running other applications

From: Björn Holmgren (bjohol_at_hotmail.com)
Date: 09/24/04


Date: Fri, 24 Sep 2004 10:22:05 +0200

In order to use the FindExecutable function, the application must be
associated with a file type (extension). You have to create a dummy file
with that extension and call FindExecutable passing the path and name of
that file.

Here's an example that locates the default browser by creating a dummy .HTM
file and calling FindExecutable:

'----------
Private Declare Function FindExecutable Lib "shell32.dll" Alias _
    "FindExecutableA" (ByVal lpFile As String, _
    ByVal lpDirectory As String, ByVal lpResult As String) As Long

Private Function DefaultBrowser() As String
    Dim strBrowser As String
    Dim strHTMFile As String
    Dim lFileNo As Long

    strHTMFile = Environ("TEMP") & "\temp.htm"

    lFileNo = FreeFile
    Open strHTMFile For Output As #lFileNo
    Print #lFileNo, "Test for default browser..."
    Close #lFileNo

    strBrowser = Space(255)
    FindExecutable strHTMFile, "", ByVal strBrowser

    Kill strHTMFile

    strBrowser = Replace(strBrowser, Chr(0), " ")
    strBrowser = Left(strBrowser, InStr(1, strBrowser, ".exe") + 3)

    DefaultBrowser = strBrowser
End Function
'----------

--
Björn Holmgren
"JaleDones" <djones_1> wrote in message
news:O93W5scoEHA.3464@tk2msftngp13.phx.gbl...
> Hi Mike,
>
> The app is a program called Data Junction.  Its an older version and it
> appears to have some functionality with automation but other than messing
> around with Word, I have very little experience with automating
> applications.
>
> I could not get the syntax correct with Data Junction.  I believe the
errors
> were something like -- ActiveX can't create object.
>
> While I have even less experience with calling API functions, your 3rd
> option of "FindExecutable" sounds enticing.  The name implies what I am
> looking for.
>
> Regards
> Dale Jones
>
>
> "MikeD" <nobody@nowhere.edu> wrote in message
> news:enJFKkcoEHA.2588@TK2MSFTNGP12.phx.gbl...
> >
> > "Dale" <daljones@accudirect.com> wrote in message
> > news:e3VUOyboEHA.1988@TK2MSFTNGP09.phx.gbl...
> > > All,
> > >
> > > I have an application I am shelling to from a certain click event.
> > >
> > > It works fine on my machine but bombs on somone elses because their
> > > installation is in another location.
> > >
> > > I know app.path would give the location of my running program but I
need
> > > something that will tell me (?search the registry) where a certain
> program
> > > is located on someone elses machine.
> > >
> > > I guess I'm trying to ask "How do I find the appplication I want to
> shell
> > > to - independent of where it is installed.
> > >
> > > I'm currently still searching my resources for an answer.
> > >
> >
> >
> > What's the application you're wanting to run. There are numerous ways to
> run
> > the app. For example, if it supports Automation, you can instantiate an
> > instance of it. If a certain file extension is associated with it, you
can
> > open the file in that app by calling the ShellExecute API function, or
get
> > the path and filename of the associated app by calling the
FindExecutable
> > API function. There are other ways as well. In order for us to tell what
> may
> > best suit your needs, you need to tell us what the app is.
> >
> > Mike
> >
> >
>
>


Relevant Pages

  • Re: How can I read a string of data sent from one program to call another?
    ... sending a command line string with the info about what server to log ... Then calling your app xfire.exe and calling the original client ...
    (comp.lang.pascal.delphi.misc)
  • Re: Does anyone know which database engine creates .TDB files?
    ... The extension may simply be generated by the app and not indicate the actual ... Many db's have a string at the beginning of the file to indicate which ... database is being used. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Open files from a file register
    ... The filesystemobject makes it fairly simple to determine the file extension ... Sub OpenDoc() ... Dim strFullName As String ... I want to be able to open the selected file - I am using some code in ...
    (microsoft.public.excel.programming)
  • Re: June 2005 EAL Question
    ... parameter to a string. ... > public class MyEventLogInstaller: Installer ... You have a web app, ... >>> at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean ...
    (microsoft.public.dotnet.general)
  • RE: SoapHttpClientProtocol request canceled
    ... the VB app on Citrix works fine with .NET components when only ... .NET1.1 is installed and the app uses .NET1.1. ... > The VB.NET exe and the VB6 exe both use VB.NET dll to sent request/response ... >> inputHeaderer, String messageControlPayload, string inputMessage) ...
    (microsoft.public.dotnet.framework.webservices)