Re: How to Open Single Instance of Program
- From: "Davy" <david@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 7 May 2005 18:29:22 +0100
Please ignore all above posts. By experimentation I have found that if I
put a /one switch in the windows file association for jpg/Irfanview then
ShellExecute does not keep loading new instances of IrfanView - and as a
bonus closes the previous image before loading the next image!
So problems solved.
cheers
Davy
"Davy" <david@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:beidndwuJNsRbeHfRVnyig@xxxxxxxxxxxxxxxxx
> Regarding the above I have just realised that this will not really solve
my
> problem. Even if I can open the graphic display program in a single
instance
> then each image will persist as a window in that program until I run out
of
> memory.
> So what I really need to do is automatically close the currently open
image
> before opening the next.
> I cannot close the program because the program reload time for each new
> image would seriously slow down the presentation to a group.
>
> cheers
>
> Davy
>
> "Davy" <david@xxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:IMGdneJkOfJaIOHfRVnytA@xxxxxxxxxxxxxxxxx
> > I have been using Dev Ashish's code which uses ShellExcute (see below)
to
> > open the registered jpg program which in my case is IrfanView. But each
> > time it runs it opens a new instance of IrfanView. This is inconvenient
> > since I am viewing more than 200 images by clicking on a thumbnail in an
> > Access 2000 database. Can anybody guide a VBA novice like myself on how
to
> > change this code to open a file in the current instance of InfranView?
It
> > needs to work both in Windows NT and 2000. IrfanView has a switch "/one"
> > which forces a single instance. Would it be sufficient to add the
switch
> to
> > the file associations in Windows?
> >
> > many thanks
> >
> > David
> >
> > ' This code was originally written by Dev Ashish.
> > ' It is not to be altered or distributed,
> > ' except as part of an application.
> > ' You are free to use it in any application,
> > ' provided the copyright notice is left unchanged.
> > '
> > ' Code Courtesy of
> > ' Dev Ashish
> > ''***************Usage Examples***********************
> > 'Open a folder: fHandleFile("C:\TEMP\",WIN_NORMAL)
> > 'Call Email app: fHandleFile("mailto:dash10@xxxxxxxxxxx",WIN_NORMAL)
> > 'Open URL: fHandleFile("http://home.att.net/~dashish",
> WIN_NORMAL)
> > 'Handle Unknown extensions (call Open With Dialog):
> > ' fHandleFile("C:\TEMP\TestThis",Win_Normal)
> > 'Start Access instance:
> > ' fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
> > '****************************************************
> > Function fHandleFile(stFile As String, lShowHow As Long)
> > Dim lRet As Long, varTaskID As Variant
> > Dim stRet As String
> > 'First try ShellExecute
> > lRet = apiShellExecute(hWndAccessApp, vbNullString, _
> > stFile, vbNullString, vbNullString, lShowHow)
> >
> > If lRet > ERROR_SUCCESS Then
> > stRet = vbNullString
> > lRet = -1
> > Else
> > Select Case lRet
> > Case ERROR_NO_ASSOC:
> > 'Try the OpenWith dialog
> > varTaskID = Shell("rundll32.exe
shell32.dll,OpenAs_RunDLL
> "
> > _
> > & stFile, WIN_NORMAL)
> > lRet = (varTaskID <> 0)
> > Case ERROR_OUT_OF_MEM:
> > stRet = "Error: Out of Memory/Resources. Couldn't
> Execute!"
> > Case ERROR_FILE_NOT_FOUND:
> > stRet = "Error: File not found. Couldn't Execute!"
> > Case ERROR_PATH_NOT_FOUND:
> > stRet = "Error: Path not found. Couldn't Execute!"
> > Case ERROR_BAD_FORMAT:
> > stRet = "Error: Bad File Format. Couldn't Execute!"
> > Case Else:
> > End Select
> > End If
> > fHandleFile = lRet & _
> > IIf(stRet = "", vbNullString, ", " & stRet)
> > End Function
> >
> >
>
>
.
- References:
- How to Open Single Instance of Program
- From: Davy
- Re: How to Open Single Instance of Program
- From: Davy
- How to Open Single Instance of Program
- Prev by Date: RE: Pasting from clipboard wonkiness
- Next by Date: Re: minute of meeting
- Previous by thread: Re: How to Open Single Instance of Program
- Next by thread: RE: Pasting from clipboard wonkiness
- Index(es):
Relevant Pages
|