none
How do I launch 123 Photo Viewer using Process.Start? RRS feed

  • Question

  • I have a program that launches several different graphics programs so I can work on an image one step at a time, such as removing background litter (InPaint), adjusting contrast, color, etc. (PhotoImpact Pro), changing size, cropping (Maximizer) and so on.

      Private Sub BtnPI_Click(sender As Object, e As EventArgs) Handles BtnPI.Click
            ClearButtons()
            BtnPI.BackColor = InUse
            HideArrows()
            ArrowAssociation.Visible = True
    
            Try
                Process.Start(strFnamePhotoImpact, InQuotes(strImage))
                ShowCurrent()
            Catch ex As Exception
    
            End Try
        End Sub

    This code works. I want to do the same for Microsoft's 123 Photo Viewer. I had put this question in the wrong forum. Castorix3 alerted me to that fact, so here it is here. He gave me an answer not using Process.Start() and for Microsoft's 'Photo Viewer', not '123 Photo Viewer'. I can't locate the .dll for it.

    The need is there are images on the net that are really .rif or .riff files but they put .jpg on them and PhotoImpact says it can't load it. Evidently, they look for the extension instead of the first few bites in the file. 123 Photo Viewer ignores the extension and loads the file. I can then save it as another file type, such as .png.

    Thanks in advance.

    LarryRichardsUS

    Friday, March 1, 2019 7:59 AM

Answers

  • Wow! I couldn't call this simple. I write a lot of Visual Basic code but nothing like that. I write utilities, some as front ends to Excel spreadsheets. I store all my movies (DVDs) on my hard drive and wrote a utility to find and run movies, keeping a history of the more than 900 movies. I use a ripper to make .mp4 files, call a shortcut to launch it.

    I use to do assembly, C, C++, C#, BASIC and Visual Basic. but I've cut down to Excel and Visual Basic 2017 now as I'm 76 years old and can't remember anything anymore.

    Thanks for the assist and I'll mull over that work you did. Really appreciate your input.

    No way to make a shortcut to that so all's I got to do is launch the shortcut? :-)

    LarryRichardsUS

    Thursday, March 14, 2019 3:50 AM

All replies

  • I'm trying to use a button to launch 123 Photo Viewer loading a gif file. How can I do it?

    Ole Smoky

    Thursday, February 28, 2019 3:40 PM
  • A way is with IApplicationActivationManager::ActivateForFile

    (application user model ID = "38623ExtremeSleeper.123ImageViewerHD_2gsdpn732f8ba!App" for 123 Photo Viewer)

    Thursday, February 28, 2019 4:54 PM
  • Castorix3, are you saying I can't use Process.Start? I don't understand how to implement it as the docs didn't  show an example. I'm not a professional programmer. Just a hobbyist since a TRS-80 model 1. What I'm trying to do is I have a utility with several buttons that launch graphic programs, depending on what I need to do. PhotoImpact Pro as my main program,  InPaint to remove unwanted areas, Maximizer for making the image larger, etc. I'm getting files with a .jpg extension but they are .rif or .riff files. It appears 123 photo viewer reads them and can convert them to .png files.

    LarryRichardsUS

    Friday, March 1, 2019 3:58 AM
  • 123 Photo Viewer is a UWP application, launched by IApplicationActivationManager (Process.Start is used for Desktop applications)

    (if it is in a particular language, as you did not mention it, the thread should be moved to the right forum (VB.NET, C#, ...)

    Friday, March 1, 2019 6:56 AM
  • I'm sorry, guess I did forget to mention that. It is in visual basic 2017.

    LarryRichardsUS

    Friday, March 1, 2019 7:16 AM
  • I just converted a C++ sample using IApplicationActivationManager into VB.NET

    The code is simple but there are a lot of declarations for Interfaces

    I tested with a .png file and last version of "123 Photo Viewer" :

    Dim pApplicationActivationManager As IApplicationActivationManager
    Dim hr As HRESULT = HRESULT.E_INVALIDARG
    ' Application user model ID for 123 Photo Viewer
    Dim sPackageName As String = "38623ExtremeSleeper.123ImageViewerHD_2gsdpn732f8ba!App"
    Dim sFile As String = "E:\sans-titre4.png"
    Dim CLSID_ApplicationActivationManager As New Guid("{45BA127D-10A8-46EA-8AB7-56EA9078943C}")
    Dim ApplicationActivationManagerType As Type = Type.GetTypeFromCLSID(CLSID_ApplicationActivationManager, True)
    Dim ApplicationActivationManager As Object = Activator.CreateInstance(ApplicationActivationManagerType)
    pApplicationActivationManager = DirectCast(ApplicationActivationManager, IApplicationActivationManager)
    If (pApplicationActivationManager IsNot Nothing) Then
        Dim pShellItemPtr As IntPtr
        Dim IDD_IShellItem As New Guid("{43826D1E-E718-42EE-BC55-A1E261C37BFE}")
        hr = SHCreateItemFromParsingName(sFile, IntPtr.Zero, IDD_IShellItem, pShellItemPtr)
        If (hr = HRESULT.S_OK) Then
            Dim pShellItemArray As IShellItemArray = Nothing
            Dim IID_IShellItemArray As New Guid("{B63EA76D-1F85-456F-A19C-48159EFA858B}")
            Dim pShellItem As IShellItem = CType(Marshal.GetObjectForIUnknown(pShellItemPtr), IShellItem)
            hr = SHCreateShellItemArrayFromShellItem(pShellItem, IID_IShellItemArray, pShellItemArray)
            If (hr = HRESULT.S_OK) Then
                Dim nProcessId As Integer = 0
                'hr = pApplicationActivationManager.ActivateApplication(sPackageName, "", ACTIVATEOPTIONS.AO_NONE, nProcessId)
                hr = pApplicationActivationManager.ActivateForFile(sPackageName, pShellItemArray, "", nProcessId)
                Marshal.ReleaseComObject(pShellItemArray)
            End If
            Marshal.Release(pShellItemPtr)
        End If
        Marshal.ReleaseComObject(pApplicationActivationManager)
    End If

    Declarations (Imports System.Runtime.InteropServices) :

    	  Public Enum HRESULT As Integer
            S_OK = 0
            S_FALSE = 1
            E_NOINTERFACE = &H80004002
            E_NOTIMPL = &H80004001
            E_FAIL = &H80004005
            E_INVALIDARG = &H80070057
        End Enum
    
        <ComImport(),
        Guid("2e941141-7f97-4756-ba1d-9decde894a3d"),
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        Public Interface IApplicationActivationManager
            Function ActivateApplication(appUserModelId As String, arguments As String, options As ACTIVATEOPTIONS, ByRef processId As Integer) As HRESULT
            Function ActivateForFile(appUserModelId As String, itemArray As IShellItemArray, verb As String, ByRef processId As Integer) As HRESULT
            Function ActivateForProtocol(appUserModelId As String, itemArray As IShellItemArray, ByRef processId As Integer) As HRESULT
        End Interface
    
        Public Enum ACTIVATEOPTIONS
            AO_NONE = 0
            AO_DESIGNMODE = &H1
            AO_NOERRORUI = &H2
            AO_NOSPLASHSCREEN = &H4
            AO_PRELAUNCH = &H2000000
        End Enum
    
        <ComImport()>
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        <Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE")>
        Public Interface IShellItem
            <PreserveSig()>
            Function BindToHandler(ByVal pbc As IntPtr, ByRef bhid As Guid, ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
            Function GetParent(ByRef ppsi As IShellItem) As HRESULT
            Function GetDisplayName(ByVal sigdnName As SIGDN, ByRef ppszName As System.Text.StringBuilder) As HRESULT
            Function GetAttributes(ByVal sfgaoMask As UInteger, ByRef psfgaoAttribs As UInteger) As HRESULT
            Function Compare(ByVal psi As IShellItem, ByVal hint As UInteger, ByRef piOrder As Integer) As HRESULT
        End Interface
    
        <ComImport, Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        Friend Interface IShellItem2
            Inherits IShellItem
            '#Region IShellItem
            <PreserveSig()>
            Overloads Function BindToHandler(ByVal pbc As IntPtr, ByRef bhid As Guid, ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
            Overloads Function GetParent(ByRef ppsi As IShellItem) As HRESULT
            Overloads Function GetDisplayName(ByVal sigdnName As SIGDN, ByRef ppszName As System.Text.StringBuilder) As HRESULT
            Overloads Function GetAttributes(ByVal sfgaoMask As UInteger, ByRef psfgaoAttribs As UInteger) As HRESULT
            Overloads Function Compare(ByVal psi As IShellItem, ByVal hint As UInteger, ByRef piOrder As Integer) As HRESULT
            '#End Region
    
            'Function GetPropertyStore(<[In]()> ByVal Flags As GETPROPERTYSTOREFLAGS, <[In]()> ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.Interface)> ByVal ppv As IPropertyStore) As HRESULT
            Function GetPropertyStore(<[In]()> ByVal Flags As GETPROPERTYSTOREFLAGS, <[In]()> ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
            Function GetPropertyStoreWithCreateObject(<[In]()> ByVal Flags As GETPROPERTYSTOREFLAGS, <[In](), MarshalAs(UnmanagedType.IUnknown)> ByVal punkCreateObject As Object, <[In]()> ByRef riid As Guid, <Out()> ByRef ppv As IntPtr) As HRESULT
            'Function GetPropertyStoreForKeys(<[In]()> ByRef rgKeys As REFPROPERTYKEY, <[In]()> ByVal cKeys As UInteger, <[In]()> ByVal Flags As GETPROPERTYSTOREFLAGS, <[In]()> ByRef riid As Guid, <Out(), MarshalAs(UnmanagedType.IUnknown)> ByVal ppv As IPropertyStore) As HRESULT
            Function GetPropertyStoreForKeys(<[In]()> ByRef rgKeys As REFPROPERTYKEY, <[In]()> ByVal cKeys As UInteger, <[In]()> ByVal Flags As GETPROPERTYSTOREFLAGS, <[In]()> ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
            Function GetPropertyDescriptionList(<[In]()> ByRef keyType As REFPROPERTYKEY, <[In]()> ByRef riid As Guid, <Out()> ByRef ppv As IntPtr) As HRESULT
            'Function Update(<[In](), MarshalAs(UnmanagedType.Interface)> ByVal pbc As IBindCtx) As HRESULT
            Function Update(<[In](), MarshalAs(UnmanagedType.Interface)> ByVal pbc As IntPtr) As HRESULT
            Function GetProperty(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef ppropvar As PROPVARIANT) As HRESULT
            Function GetCLSID(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef pclsid As Guid) As HRESULT
    
            <PreserveSig>
            Function GetFileTime(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef pft As System.Runtime.InteropServices.ComTypes.FILETIME) As HRESULT
            Function GetInt32(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef pi As Integer) As HRESULT
            Function GetString(<[In]()> ByRef key As REFPROPERTYKEY, <Out(), MarshalAs(UnmanagedType.LPWStr)> ByRef ppsz As String) As HRESULT
            Function GetUInt32(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef pui As UInteger) As HRESULT
            Function GetUInt64(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef pull As ULong) As HRESULT
            Function GetBool(<[In]()> ByRef key As REFPROPERTYKEY, <Out()> ByRef pf As Integer) As HRESULT
        End Interface
    
        Public Enum GETPROPERTYSTOREFLAGS
            GPS_DEFAULT = 0
            GPS_HANDLERPROPERTIESONLY = &H1
            GPS_READWRITE = &H2
            GPS_TEMPORARY = &H4
            GPS_FASTPROPERTIESONLY = &H8
            GPS_OPENSLOWITEM = &H10
            GPS_DELAYCREATION = &H20
            GPS_BESTEFFORT = &H40
            GPS_NO_OPLOCK = &H80
            GPS_PREFERQUERYPROPERTIES = &H100
            GPS_EXTRINSICPROPERTIES = &H200
            GPS_EXTRINSICPROPERTIESONLY = &H400
            GPS_MASK_VALID = &H7FF
        End Enum
    
        <StructLayout(LayoutKind.Sequential, Pack:=4)>
        Public Structure REFPROPERTYKEY
            Private fmtid As Guid
            Private pid As Integer
            Public ReadOnly Property FormatId() As Guid
                Get
                    Return Me.fmtid
                End Get
            End Property
            Public ReadOnly Property PropertyId() As Integer
                Get
                    Return Me.pid
                End Get
            End Property
            Public Sub New(ByVal formatId As Guid, ByVal propertyId As Integer)
                Me.fmtid = formatId
                Me.pid = propertyId
            End Sub
            Public Shared ReadOnly PKEY_DateCreated As REFPROPERTYKEY = New REFPROPERTYKEY(New Guid("B725F130-47EF-101A-A5F1-02608C9EEBAC"), 15)
        End Structure
    
        Public Enum SIATTRIBFLAGS
            SIATTRIBFLAGS_AND = &H1
            SIATTRIBFLAGS_OR = &H2
            SIATTRIBFLAGS_APPCOMPAT = &H3
            SIATTRIBFLAGS_MASK = &H3
            SIATTRIBFLAGS_ALLITEMS = &H4000
        End Enum
    
        Public Const DROPEFFECT_NONE = 0
        Public Const DROPEFFECT_COPY = 1
        Public Const DROPEFFECT_MOVE = 2
        Public Const DROPEFFECT_LINK = 4
    
        Public Const SFGAO_CANCOPY = DROPEFFECT_COPY ' Objects can be copied    (= &H1)
        Public Const SFGAO_CANMOVE = DROPEFFECT_MOVE ' Objects can be moved     (= &H2)
        Public Const SFGAO_CANLINK = DROPEFFECT_LINK ' Objects can be linked    (= &H4)
        Public Const SFGAO_STORAGE = &H8L     ' supports BindToObject(IID_IStorage)
        Public Const SFGAO_CANRENAME = &H10L     ' Objects can be renamed
        Public Const SFGAO_CANDELETE = &H20L     ' Objects can be deleted
        Public Const SFGAO_HASPROPSHEET = &H40L     ' Objects have property sheets
        Public Const SFGAO_DROPTARGET = &H100L     ' Objects are drop target
        Public Const SFGAO_CAPABILITYMASK = &H177L
        Public Const SFGAO_SYSTEM = &H1000L     ' System object
        Public Const SFGAO_ENCRYPTED = &H2000L     ' Object is encrypted (use alt color)
        Public Const SFGAO_ISSLOW = &H4000L     ' 'Slow' object
        Public Const SFGAO_GHOSTED = &H8000L     ' Ghosted icon
        Public Const SFGAO_LINK = &H10000L     ' Shortcut (link)
        Public Const SFGAO_SHARE = &H20000L     ' Shared
        Public Const SFGAO_READONLY = &H40000L     ' Read-only
        Public Const SFGAO_HIDDEN = &H80000L     ' Hidden object
        Public Const SFGAO_DISPLAYATTRMASK = &HFC000L
        Public Const SFGAO_FILESYSANCESTOR = &H10000000L     ' May contain children with SFGAO_FILESYSTEM
        Public Const SFGAO_FOLDER = &H20000000L     ' Support BindToObject(IID_IShellFolder)
        Public Const SFGAO_FILESYSTEM = &H40000000L     ' Is a win32 file system object (file/folder/root)
        Public Const SFGAO_HASSUBFOLDER = &H80000000L     ' May contain children with SFGAO_FOLDER (may be slow)
        Public Const SFGAO_CONTENTSMASK = &H80000000L
        Public Const SFGAO_VALIDATE = &H1000000L     ' Invalidate cached information (may be slow)
        Public Const SFGAO_REMOVABLE = &H2000000L     ' Is this removeable media?
        Public Const SFGAO_COMPRESSED = &H4000000L     ' Object is compressed (use alt color)
        Public Const SFGAO_BROWSABLE = &H8000000L     ' Supports IShellFolder, but only implements CreateViewObject() (non-folder view)
        Public Const SFGAO_NONENUMERATED = &H100000L     ' Is a non-enumerated object (should be hidden)
        Public Const SFGAO_NEWCONTENT = &H200000L     ' Should show bold in explorer tree
        Public Const SFGAO_CANMONIKER = &H400000L     ' Obsolete
        Public Const SFGAO_HASSTORAGE = &H400000L     ' Obsolete
        Public Const SFGAO_STREAM = &H400000L     ' Supports BindToObject(IID_IStream)
        Public Const SFGAO_STORAGEANCESTOR = &H800000L     ' May contain children with SFGAO_STORAGE or SFGAO_STREAM
        Public Const SFGAO_STORAGECAPMASK = &H70C50008L     ' For determining storage capabilities, ie for open/save semantics
        Public Const SFGAO_PKEYSFGAOMASK = &H81044000L     ' Attributes that are masked out for PKEY_SFGAOFlags because they are considered to cause slow calculations or lack context (SFGAO_VALIDATE | SFGAO_ISSLOW | SFGAO_HASSUBFOLDER and others)
    
        Enum SIGDN As Integer
            SIGDN_NORMALDISPLAY = &H0
            SIGDN_PARENTRELATIVEPARSING = &H80018001
            SIGDN_DESKTOPABSOLUTEPARSING = &H80028000
            SIGDN_PARENTRELATIVEEDITING = &H80031001
            SIGDN_DESKTOPABSOLUTEEDITING = &H8004C000
            SIGDN_FILESYSPATH = &H80058000
            SIGDN_URL = &H80068000
            SIGDN_PARENTRELATIVEFORADDRESSBAR = &H8007C001
            SIGDN_PARENTRELATIVE = &H80080001
        End Enum
    
        <StructLayout(LayoutKind.Sequential)>
        Public Structure PROPARRAY
            Public cElems As UInteger
            Public pElems As IntPtr
        End Structure
    
        <StructLayout(LayoutKind.Explicit, Pack:=1)>
        Public Structure PROPVARIANT
            <FieldOffset(0)>
            Public varType As System.UInt16
            <FieldOffset(2)>
            Public wReserved1 As System.UInt16
            <FieldOffset(4)>
            Public wReserved2 As System.UInt16
            <FieldOffset(6)>
            Public wReserved3 As System.UInt16
            <FieldOffset(8)>
            Public bVal As Byte
            <FieldOffset(8)>
            Public cVal As System.SByte
            <FieldOffset(8)>
            Public uiVal As System.UInt16
            <FieldOffset(8)>
            Public iVal As Short
            <FieldOffset(8)>
            Public uintVal As UInt32
            <FieldOffset(8)>
            Public intVal As Int32
            <FieldOffset(8)>
            Public ulVal As UInt64
            <FieldOffset(8)>
            Public lVal As Int64
            <FieldOffset(8)>
            Public fltVal As Single
            <FieldOffset(8)>
            Public dblVal As Double
            <FieldOffset(8)>
            Public boolVal As Short
            <FieldOffset(8)>
            Public pclsidVal As IntPtr
            ' GUID ID pointer
            <FieldOffset(8)>
            Public pszVal As IntPtr
            ' Ansi string pointer
            <FieldOffset(8)>
            Public pwszVal As IntPtr
            ' Unicode string pointer
            <FieldOffset(8)>
            Public punkVal As IntPtr
            ' punkVal (interface pointer)
            <FieldOffset(8)>
            Public ca As PROPARRAY
            <FieldOffset(8)>
            Public filetime As System.Runtime.InteropServices.ComTypes.FILETIME
        End Structure
    
        <ComImport()>
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        <Guid("b63ea76d-1f85-456f-a19c-48159efa858b")>
        Public Interface IShellItemArray
            'Function BindToHandler(pbc As IBindCtx, ByRef bhid As Guid, ByRef riid As Guid, ByRef ppvOut As IntPtr) As HRESULT
            Function BindToHandler(pbc As IntPtr, ByRef bhid As Guid, ByRef riid As Guid, ByRef ppvOut As IntPtr) As HRESULT
            Function GetPropertyStore(flags As GETPROPERTYSTOREFLAGS, ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
            Function GetPropertyDescriptionList(keyType As REFPROPERTYKEY, ByRef riid As Guid, ByRef ppv As IntPtr) As HRESULT
            'Function GetAttributes(AttribFlags As SIATTRIBFLAGS, sfgaoMask As SFGAOF, ByRef psfgaoAttribs As SFGAOF) As HRESULT
            Function GetAttributes(AttribFlags As SIATTRIBFLAGS, sfgaoMask As Integer, ByRef psfgaoAttribs As Integer) As HRESULT
            Function GetCount(ByRef pdwNumItems As Integer) As HRESULT
            Function GetItemAt(dwIndex As Integer, ByRef ppsi As IShellItem) As HRESULT
            'Function EnumItems(ByRef ppenumShellItems As IEnumShellItems) As HRESULT
            Function EnumItems(ByRef ppenumShellItems As IntPtr) As HRESULT
        End Interface
    
        <ComImport(),
        InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
        Guid("70629033-e363-4a28-a567-0db78006e6d7")>
        Public Interface IEnumShellItems
            <PreserveSig()>
            Function [Next](ByVal celt As UInteger, ByRef rgelt As IShellItem, ByRef pceltFetched As UInteger) As HRESULT
            Function Skip(ByVal celt As UInteger) As HRESULT
            Function Reset() As HRESULT
            Function Clone(ByRef ppenum As IEnumShellItems) As HRESULT
        End Interface
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)>
        Public Shared Function SHCreateItemFromParsingName(pszPath As String, pbc As IntPtr, <[In], MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, <Out> ByRef ppv As IntPtr) As HRESULT
        End Function
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)>
        Public Shared Function SHCreateShellItemArrayFromShellItem(psi As IShellItem, <[In], MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, <Out> ByRef ppv As IShellItemArray) As HRESULT
        End Function

    Friday, March 1, 2019 11:58 AM
  • Wow! I couldn't call this simple. I write a lot of Visual Basic code but nothing like that. I write utilities, some as front ends to Excel spreadsheets. I store all my movies (DVDs) on my hard drive and wrote a utility to find and run movies, keeping a history of the more than 900 movies. I use a ripper to make .mp4 files, call a shortcut to launch it.

    I use to do assembly, C, C++, C#, BASIC and Visual Basic. but I've cut down to Excel and Visual Basic 2017 now as I'm 76 years old and can't remember anything anymore.

    Thanks for the assist and I'll mull over that work you did. Really appreciate your input.

    No way to make a shortcut to that so all's I got to do is launch the shortcut? :-)

    LarryRichardsUS

    Thursday, March 14, 2019 3:50 AM