Question about Larry Rebich's ShellAndWait 
Author Message
 Question about Larry Rebich's ShellAndWait

I have been trying to get the ShellAndWait routine written by Larry Rebich
located here
http://www.*-*-*.com/
 to open a jpg file within a program, but I have not been able to get it to
work.

Passing the path of the jpg to CreateProcess returns the value of zero, but
the same path works in ShellExecute.

Is there anyway to get CreateProcess to open a jpg file or am I missing
something, which is usually the case. :-)

Thanks,
Norm



Tue, 14 Dec 2010 04:49:17 GMT  
 Question about Larry Rebich's ShellAndWait

Quote:

> I have been trying to get the ShellAndWait routine written by Larry Rebich
> located here
> http://www.buygold.net/tips.html
> to open a jpg file within a program, but I have not been able to get it to
> work.

> Passing the path of the jpg to CreateProcess returns the value of zero, but
> the same path works in ShellExecute.

> Is there anyway to get CreateProcess to open a jpg file or am I missing
> something, which is usually the case. :-)

CreateProcess does just that.  You'll need to pass the name of the executable you
want to start.  As I recall, it also supports a command line, so if that app
supports passing a filename you'll be all set.
--
.NET: It's About Trust!
 http://vfred.mvps.org


Tue, 14 Dec 2010 05:06:41 GMT  
 Question about Larry Rebich's ShellAndWait



Quote:

> > I have been trying to get the ShellAndWait routine written by Larry
Rebich
> > located here
> > http://www.buygold.net/tips.html
> > to open a jpg file within a program, but I have not been able to get it
to
> > work.

> > Passing the path of the jpg to CreateProcess returns the value of zero,
but
> > the same path works in ShellExecute.

> > Is there anyway to get CreateProcess to open a jpg file or am I missing
> > something, which is usually the case. :-)

> CreateProcess does just that.  You'll need to pass the name of the
executable you
> want to start.  As I recall, it also supports a command line, so if that
app
> supports passing a filename you'll be all set.
> --
> .NET: It's About Trust!
>  http://vfred.mvps.org

Karl,

I have tried this without success, where sCommand contains the path to the
jpg file
and I am not using any of the log functions. You might have to full screen
your reader
to see the full lines.

Norm

Public Function ShellAndWait(tShellAndWait As udtShellAndWait) As Boolean
' 1998/10/07 Add optional log and times
' 1998/10/27 Add DoEvents to allow the process to be terminated. Move
tProcess to caller.

    Dim lRtn    As Long
    Dim iFN     As Integer
    Dim lMilliseconds As Long

    With tShellAndWait
        .dStart = Now                       'started now
        .bTerminated = False                'set not terminated yet into
structure
        .dTerminated = 0                    'not terminated at this point
        lMilliseconds = .lMilliseconds      'local variable
        If lMilliseconds <= 0 Then          'zero or negative then use 1
second
            lMilliseconds = mclMillisecondsDefault  'default
        End If
        If .bNoTerminate Then               'don't allow terminate
            .lMilliseconds = INFINITE       'set to never return
        End If
        .bShellAndWaitRunning = True        'started

        ' Initialize the STARTUPINFO structure:
        .tStart.cb = Len(.tStart)

        ' Start the shelled application: sCommand = Path to jpg file
        lRtn = CreateProcessA("ShellExecute", .sCommand, 0&, 0&, 1&,
NORMAL_PRIORITY_CLASS, 0&, 0&, .tStart, .tProcess)

        ' Wait for the shelled application to finish:
        Do
            lRtn = WaitForSingleObject(.tProcess.hProcess, lMilliseconds)
'wait milliseconds
            If lRtn <> WAIT_TIMEOUT Then
                Exit Do
            End If
            DoEvents                                'allow other processes
        Loop While True

        lRtn = CloseHandle(.tProcess.hProcess)
        If lRtn <> 0 Then
            ShellAndWait = True                     'report success
        End If
        .bShellAndWaitRunning = False               'ended

        On Error GoTo ShellAndWaitExit              'skip log if any error
        .dFinish = Now
        .dDiff = .dFinish - .dStart
        If .bLogFile Then                           'write the log
            KillLogFileIfTooBig tShellAndWait       'can't let it get too
big
            iFN = FreeFile                          'get a file handle
            Open .sLogFile For Append As iFN        'Add to an existing file
            Print #iFN, Format$(.dStart, "general date"); ", ";     'started
            Print #iFN, Format$(.dFinish, "general date"); ", ";
'finished
            Print #iFN, Format$(.dDiff, "Hh.Nn.Ss"); " ";
'duration
            Print #iFN, .sCommand                   'command executed
            Close #iFN
        End If
    End With
ShellAndWaitExit:
End Function



Tue, 14 Dec 2010 06:07:14 GMT  
 Question about Larry Rebich's ShellAndWait

Quote:



>> > I have been trying to get the ShellAndWait routine written by Larry Rebich
>> > located here
>> > http://www.buygold.net/tips.html
>> > to open a jpg file within a program, but I have not been able to get it to
>> > work.

>> > Passing the path of the jpg to CreateProcess returns the value of zero, but
>> > the same path works in ShellExecute.

>> > Is there anyway to get CreateProcess to open a jpg file or am I missing
>> > something, which is usually the case. :-)

>> CreateProcess does just that.  You'll need to pass the name of the executable you
>> want to start.  As I recall, it also supports a command line, so if that app
>> supports passing a filename you'll be all set.

> I have tried this without success, where sCommand contains the path to the jpg
> file
> and I am not using any of the log functions. You might have to full screen
> your reader to see the full lines.

Ah, well, ShellExecute isn't an executable.  It's an API, just like CreateProcess.

   ShellExecute Function ()
   http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

In order to use CreateProcess, you'll have to tell it which process to create.  The
utility of ShellExecute is that it does the registry lookup for you to find the
associated application for your datafile.
--
.NET: It's About Trust!
 http://vfred.mvps.org



Tue, 14 Dec 2010 06:16:01 GMT  
 Question about Larry Rebich's ShellAndWait
Boy talk about feeling like a dummy. :-) I guess it takes a while for this
to sink in.

Using IExplore.exe works just fine.

Thanks,
Norm



Tue, 14 Dec 2010 07:11:52 GMT  
 Question about Larry Rebich's ShellAndWait

Quote:

> Boy talk about feeling like a dummy. :-) I guess it takes a while for this
> to sink in.

We've all been there, believe me!

Quote:
> Using IExplore.exe works just fine.

Well, only because it happens to be on the search path.  You might also be
interested in the FindExecutable API?

  http://msdn.microsoft.com/en-us/library/bb776419(VS.85).aspx

--
.NET: It's About Trust!
 http://vfred.mvps.org



Tue, 14 Dec 2010 07:23:30 GMT  
 Question about Larry Rebich's ShellAndWait



Quote:

> > Boy talk about feeling like a dummy. :-) I guess it takes a while for
this
> > to sink in.

> We've all been there, believe me!

> > Using IExplore.exe works just fine.

> Well, only because it happens to be on the search path.  You might also be
> interested in the FindExecutable API?

>   http://msdn.microsoft.com/en-us/library/bb776419(VS.85).aspx

> --
> .NET: It's About Trust!
>  http://vfred.mvps.org

Thanks Karl,

I am already using the FindExecutable API. That one I figured out. :-)

Norm



Tue, 14 Dec 2010 08:56:51 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Atten: Larry Serflaten - Re: Dictionary Questions, Questions, Questions

2. I Hope it's Larry's Day Off

3. Larry won't answer!

4. Hard Question (Larry, Michael ???) - MAC Addresses

5. ShellAndWait routine/making VB wait for DOS apps

6. Help with VB3 ShellAndWait in .EXE vs. Debug

7. To Larry Linson

8. PRICK ALERT: LARRY LINSON

9. What happened to Larry Linson?

10. Does Larry Linson give head?

11. Edward, Larry and Joe - Thank you!

12. Does Larry Linson eat poo?

 

 
Powered by phpBB® Forum Software