Re: How to Open Single Instance of Program

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
> >
> >
>
>


.



Relevant Pages

  • Re: Cant open file in Office 2003 Word or Excel from Windows Expl
    ... deleted the DOC file association and then ... Then re-register Word by typing winword /r in Windows Start> Run. ... my WORD icon and the file opens normally. ...
    (microsoft.public.word.docmanagement)
  • Re: Cant open file in Office 2003 Word or Excel from Windows Expl
    ... I looked at the file association directly and found one difference from the ... From Windows Explorer, right click a document ... I am able to drag a .doc file from Windows Explorer to my ... WORD icon and the file opens normally. ...
    (microsoft.public.word.docmanagement)
  • Re: printing all kind of files
    ... I tried ShellExecute() with "print" parameter. ... viewer instead of printing it directly. ... it opens the print dialog. ... Many file extensions on Windows have associated programs ...
    (microsoft.public.vc.language)
  • Re: running another application from VBA
    ... extension to look up the program that will open the file. ... To create a file association for an unassociated file type: ... In My Computer or Windows Explorer, ... Unless you want to find and download software that opens this file ...
    (microsoft.public.excel.programming)
  • Re: Trying to open Secured PDF from VB
    ... If I do a Start | Run | g:\test\manual.pdf, the file opens in the Windows associated program (Acrobat Reader) with the titlebar showing "Manual.pdf ". ... When in Visual Basic, if I issue a ShellExecute command that basically does the same thing, but I get a "File Not Found" error returned and Acrobat never opens. ... I don't understand why it'll open using Windows just fine but when called from VB it errors. ...
    (microsoft.public.vb.winapi)