Execute other Program...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scott D. Barrish

    Execute other Program...

    On my form, I have a field that displays the student's website. How do I
    display thewebsite as a hyperlink in a textbox where the user can click on
    it and Internet Explorer opens up the site?


  • CajunCoiler \(http://www.cajuncoiler.tk\)

    #2
    Re: Execute other Program...

    If that's all that's in that textbox, then the solution is simple... just
    set up
    a CLICK event on the textbox, that passes it's contents to a SHELLEXECUTE
    API call. Over here, I have this API call pre-defined as "runfile" in a
    module called "shellexec" , so in this situation, I would only need to do...

    Private Sub Text1_Click()
    ShellExec.RunFi le Text1.Text
    End Sub

    "Scott D. Barrish" <sbarrish@tampa bay.rr.com> wrote in message
    news:iHfcb.9441 $eS5.5253@twist er.tampabay.rr. com...[color=blue]
    > On my form, I have a field that displays the student's website. How do I
    > display thewebsite as a hyperlink in a textbox where the user can click on
    > it and Internet Explorer opens up the site?[/color]


    Comment

    • Scott D. Barrish

      #3
      Re: Execute other Program...

      Thank you for your help.

      I accomplished my task with the following:

      Shell("c:\progr am files\internet explorer\iexplo re.exe " & lblLink.Caption ,
      vbMaximizedFocu s)

      Sincerely,
      Scott D. Barrish


      Comment

      • J French

        #4
        Re: Execute other Program...

        On Thu, 25 Sep 2003 04:17:43 GMT, "Scott D. Barrish"
        <sbarrish@tampa bay.rr.com> wrote:
        [color=blue]
        >Thank you for your help.
        >
        >I accomplished my task with the following:
        >
        >Shell("c:\prog ram files\internet explorer\iexplo re.exe " & lblLink.Caption ,
        >vbMaximizedFoc us)[/color]

        It might be an idea to programatically find the file name and location
        of the default browser

        The API FindExecutable( ) is useful for that

        Comment

        • Scott D. Barrish

          #5
          Re: Execute other Program...

          I used the following code:

          Private Declare Function ShellExecute _
          Lib "shell32.dl l" _
          Alias "ShellExecuteA" ( _
          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 Sub lbl_Link_Click( )
          Dim r As Long
          r = ShellExecute(0, "open", lbl_Link.Captio n,0, 0, 1)
          End Sub


          "J French" <erewhon@nowher e.com> wrote in message
          news:3f729961.7 [email protected] lick.com...[color=blue]
          > On Thu, 25 Sep 2003 04:17:43 GMT, "Scott D. Barrish"
          > <sbarrish@tampa bay.rr.com> wrote:
          >[color=green]
          > >Thank you for your help.
          > >
          > >I accomplished my task with the following:
          > >
          > >Shell("c:\prog ram files\internet explorer\iexplo re.exe " &[/color][/color]
          lblLink.Caption ,[color=blue][color=green]
          > >vbMaximizedFoc us)[/color]
          >
          > It might be an idea to programatically find the file name and location
          > of the default browser
          >
          > The API FindExecutable( ) is useful for that
          >[/color]


          Comment

          • J French

            #6
            Re: Execute other Program...

            On Thu, 25 Sep 2003 16:11:32 GMT, "Scott D. Barrish"
            <sbarrish@tampa bay.rr.com> wrote:
            [color=blue]
            >I used the following code:
            >
            >Private Declare Function ShellExecute _
            > Lib "shell32.dl l" _
            > Alias "ShellExecuteA" ( _
            > 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
            >[/color]

            Yes, that is fine - provided one small thing ....

            That you are sure that ShellExecute will recognize the 'file' that you
            are sending it

            Having to launch a browser to try to go to all sorts of dubiously
            formatted web addresses, I opt for finding the App's name and then
            launching it myself

            That way I am sure a Browser will get launched ...

            Think about it for a bit ...
            - I spent some time worrying over the problem

            Of course FindExecutable is fundamentally faulty, as it might launch a
            DDE server - and also (stupidly) needs an existing file
            - but give it c:\temp\dummy.h tm and it comes back with a browser

            - the other (safe) method is to ponce around in the registry looking
            for the file associated with 'htm'
            - having nailed that down once, I don't like using it


            Comment

            • xyz

              #7
              Re: Execute other Program... - HAND-M.CUR (0/1)

              On Wed, 24 Sep 2003 12:00:14 GMT, "Scott D. Barrish"
              <sbarrish@tampa bay.rr.com> wrote:
              [color=blue]
              >On my form, I have a field that displays the student's website. How do I
              >display thewebsite as a hyperlink in a textbox where the user can click on
              >it and Internet Explorer opens up the site?
              >[/color]

              =============== =====
              I recently had to solve this problem. It is different for Windows
              95,98,ME and Windows NT,2000,XP. Here is a cross-system solution.

              Place a "Microsoft SysInfo control" on your form. Set the "label"
              field that displays the web site URL to be underlined in the Font
              attribute, set the MousePointer attribute to 99 (custom), and set the
              MouseIcon to HAND-M.CUR (it is normally in the /windows/cursors
              directory, I attached it). This will cause the web hand to show when
              the cursor is placed over the label that has the web link.


              ' The declaration below goes in a Module1.bas file
              ' execute shell command
              Declare Function ShellExecute Lib "shell32.dl l" _
              Alias "ShellExecu teA" (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


              ' This is the code to launch the browser (It assumes that
              ' the form with the SysInfo control is frmMain
              Private Sub Label5_Click()

              Dim rcu As Long
              Dim URL As String
              ' ShellExecute defined in Module1.bas

              URL = "http://www.yahoo.com/" ' or whatever

              If frmMain.SysInfo 1.OSPlatform = 2 Then
              ' OSPlatform = 2 for Win NT/2000/XP
              Call ShellExecute(Me .hwnd, "open", URL, "", "", 0)
              Else
              ' OSPlatform = 1 for Win 95/98/ME
              rcu = Shell("start " & URL, vbNormalFocus)
              End If
              End Sub




              Comment

              • xyz

                #8
                Re: Execute other Program... - HAND-M.CUR (1/1)



                Comment

                • Aristotelis E. Charalampakis

                  #9
                  Re: Execute other Program...

                  Iexplorer.exe is not the only browser out there.

                  I think one should try to locate the browser associated with the htm files,
                  as you say. However I dont I dont know how :-)

                  A.



                  "J French" <erewhon@nowher e.com> wrote in message
                  news:3f7321db.9 [email protected] lick.com...[color=blue]
                  > On Thu, 25 Sep 2003 16:11:32 GMT, "Scott D. Barrish"
                  > <sbarrish@tampa bay.rr.com> wrote:
                  >[color=green]
                  > >I used the following code:
                  > >
                  > >Private Declare Function ShellExecute _
                  > > Lib "shell32.dl l" _
                  > > Alias "ShellExecuteA" ( _
                  > > 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
                  > >[/color]
                  >
                  > Yes, that is fine - provided one small thing ....
                  >
                  > That you are sure that ShellExecute will recognize the 'file' that you
                  > are sending it
                  >
                  > Having to launch a browser to try to go to all sorts of dubiously
                  > formatted web addresses, I opt for finding the App's name and then
                  > launching it myself
                  >
                  > That way I am sure a Browser will get launched ...
                  >
                  > Think about it for a bit ...
                  > - I spent some time worrying over the problem
                  >
                  > Of course FindExecutable is fundamentally faulty, as it might launch a
                  > DDE server - and also (stupidly) needs an existing file
                  > - but give it c:\temp\dummy.h tm and it comes back with a browser
                  >
                  > - the other (safe) method is to ponce around in the registry looking
                  > for the file associated with 'htm'
                  > - having nailed that down once, I don't like using it
                  >
                  >[/color]


                  Comment

                  • J French

                    #10
                    Re: Execute other Program...

                    On Fri, 26 Sep 2003 20:48:50 +0300, "Aristoteli s E. Charalampakis"
                    <aristotelis_ch aralampakis@REM OVEMEhotmail.co m> wrote:
                    [color=blue]
                    >Iexplorer.ex e is not the only browser out there.
                    >
                    >I think one should try to locate the browser associated with the htm files,
                    >as you say. However I dont I dont know how :-)
                    >[/color]
                    1) ShellExecute() finds and runs the browser

                    2) FindExecutable( ) finds the browser - you need to run it (good)

                    3) Peer into the Registry - Ok - but can be tedious



                    Comment

                    • Aristotelis E. Charalampakis

                      #11
                      Re: Execute other Program...

                      mmm, of course you are right.

                      Should have checked before opening my mouth. I wasnt aware of this api, but
                      appleman is clear:

                      FindExecutable

                      Finds the file name of the program that is associated with a specified file.
                      The Windows registration editor can be used to associate types of files with
                      particular applications. For example, text files that have the extension
                      ..TXT are typically associated with the Windows Notepad (NOTEPAD.EXE).

                      Cheers

                      "J French" <erewhon@nowher e.com> wrote in message
                      news:3f748bea.3 [email protected] click.com...[color=blue]
                      > On Fri, 26 Sep 2003 20:48:50 +0300, "Aristoteli s E. Charalampakis"
                      > <aristotelis_ch aralampakis@REM OVEMEhotmail.co m> wrote:
                      >[color=green]
                      > >Iexplorer.ex e is not the only browser out there.
                      > >
                      > >I think one should try to locate the browser associated with the htm[/color][/color]
                      files,[color=blue][color=green]
                      > >as you say. However I dont I dont know how :-)
                      > >[/color]
                      > 1) ShellExecute() finds and runs the browser
                      >
                      > 2) FindExecutable( ) finds the browser - you need to run it (good)
                      >
                      > 3) Peer into the Registry - Ok - but can be tedious
                      >
                      >
                      >[/color]


                      Comment

                      • J French

                        #12
                        Re: Execute other Program...

                        On Sat, 27 Sep 2003 09:21:58 +0300, "Aristoteli s E. Charalampakis"
                        <aristotelis_ch aralampakis@REM OVEMEhotmail.co m> wrote:
                        [color=blue]
                        >mmm, of course you are right.
                        >
                        >Should have checked before opening my mouth. I wasnt aware of this api, but
                        >appleman is clear:
                        >
                        >FindExecutab le
                        >
                        >Finds the file name of the program that is associated with a specified file.
                        >The Windows registration editor can be used to associate types of files with
                        >particular applications. For example, text files that have the extension
                        >.TXT are typically associated with the Windows Notepad (NOTEPAD.EXE).[/color]

                        The only 'gotcha' is that you have to give it the name of a file that
                        actually exists.

                        So if I want to go to 'www.borland.co m'
                        then I create a file called : 'c:\temp\dummy. htm'

                        Use FindExecutable( ) to find the EXE for 'c:\temp\dummy. htm'
                        Then launch that EXE with the 'real' target in the command line

                        A bit silly of MS to make the file have to exist, but there are some
                        legacy DDE considerations that I've chosen to ignore.


                        Comment

                        • J French

                          #13
                          Re: Execute other Program...

                          On Sat, 27 Sep 2003 09:21:58 +0300, "Aristoteli s E. Charalampakis"
                          <aristotelis_ch aralampakis@REM OVEMEhotmail.co m> wrote:
                          [color=blue]
                          >mmm, of course you are right.
                          >
                          >Should have checked before opening my mouth. I wasnt aware of this api, but
                          >appleman is clear:
                          >[/color]
                          Dunno, by asking you've found something fairly obscure ...

                          Oops - I meant to post this

                          This link might also be useful :-

                          Obtaining the Path and Filename of the Default Browser

                          Comment

                          Working...