sketchucation logo sketchucation
    • Login
    šŸ¤‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    OpenURL and/or ShellExecute on Vista

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 3 Posters 1.0k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Al HartA Offline
      Al Hart
      last edited by

      My UI.openURL calls to launch an image are failing in Vista.

      They work ok on XP, and they work OK in Vista for text files rather than images;

      This works:

      UI.openURL("c:/tmp/test3.txt")

      This fails:

      UI.openURL("c:/tmp/test2.jpg")

      even though both files exist.

      I am reading about problems with Windows ShellExecute in vista getting permission denied errors.
      (I tried using Win32API and SkellExecute - but it has the same problems)

      I see in another post that TIG was having similar problems trying to load a PDF file.


      Has anyone learned any more about it?

      Al Hart

      http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
      IRender nXt from Render Plus

      1 Reply Last reply Reply Quote 0
      • Al HartA Offline
        Al Hart
        last edited by

        After some research, I discovered when I was calling ShellExecute from Win32API, that I was passing the action "open". Open does not exist imageds on Vista. (You can right click on an image to see that the two choice are Edit and Preview). When I change "open" to "" (blank), it worked, but UI.openURL() still does not work. I suspect that SketchUp has made the same mistake and implemented openURL() in such a way that it passes the verb "open".

        Al Hart

        http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
        IRender nXt from Render Plus

        1 Reply Last reply Reply Quote 0
        • tbdT Offline
          tbd
          last edited by

          ShellExecute API has open verb (see documentation). it has nothing to do with right click menu which can be modified to anything (e.g. mysuperduperopenfunctionthatdoesntwork)

          you need to trace down the API to see what the real error is (wrong path, bad associations, no privileges, ...)

          SketchUp Ruby Consultant | Podium 1.x developer
          http://plugins.ro

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            First try changing the default application that opens jpg's - I guess you'll have IE set... Another exe will probably open them. I think the Vista security craziness extends into stopping apps running in IE so web originating exe incursions are stopped, and it includes opening any file like a jpg that might contain hidden 'nastiness'...

            The internet settings for IE could also be adjusted to see if that helps...

            TIG

            1 Reply Last reply Reply Quote 0
            • Al HartA Offline
              Al Hart
              last edited by

              Perhaps the user can add any ShellExecute verbs they want, but in Vista, the default for images does not have an "open" verb.

              Here is a right click on a text file.

              right-click1.PNG

              Here is a right click on an image.

              right-click2.PNG

              So when you issue an "open" on an image, ShellExecute fails.

              If you leave out the verb, then both txt and jpg use the default (bold) action.

              
              shell = Win32API.new("shell32","ShellExecute", ['L','P','P','P','P','L'], 'L' )
              #<Win32API;0x5a8e290>
              #shell.call(handle, verb, file, params, folder, showCmd)
              nil
              shell.call(0, "open", "c;/docs/Apples.jpg", "", "", 1)
              31
              shell.call(0, "edit", "c;/docs/Apples.jpg", "", "", 1)
              42
              shell.call(0, "", "c;/docs/Apples.jpg", "", "", 1)
              42
              
              

              In the code above, "open" fails and returns 31 - ERROR_GEN_FAILURE
              "edit" loads the image properly, and "" loads the image properly.

              Al Hart

              http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
              IRender nXt from Render Plus

              1 Reply Last reply Reply Quote 0
              • tbdT Offline
                tbd
                last edited by

                I have open for images in my Vista šŸ˜‰

                if you use "" it is the same as giving NULL to ShellExecute which takes in this order:

                • the default one (the bold text),
                • then the "open" verb
                • then the first item in registry.

                error 31 is "There is no application associated with the given file name extension" which in your case is true.

                SketchUp Ruby Consultant | Podium 1.x developer
                http://plugins.ro

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  @al hart said:

                  Perhaps the user can add any ShellExecute verbs they want, but in Vista, the default for images does not have an "open" verb.
                  In my Vista jpgs DO happily have Open with the default[bold] right-click verb 'Open', listed after that is Edit, Print etc... However I do recall something messing up with Vista for me on some file-type, where the double-click on the icon stopped 'Open'ing the file is the associated app - much like you show... I fixed it by hacking around in the Registry and swapping Open/Edit around etc - can't remember what or where... Caused by installing some 3rd party app that I removed...

                  On my Vista jpgs will open fine with UI.openURL(), whatever the jpg default app is set to, including IE, and they all show 'Open' as their default clicking action...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • Al HartA Offline
                    Al Hart
                    last edited by

                    I'll have to look at my other Vista machines and see if they have open as a default.
                    Perhaps a Photo program I downloaded changed the settings.
                    (Or I have read that the setting may depend on your default Internet Browser)

                    In Googleing around I see where others are having similar problems with Shell Execute in Vista.

                    I need a solution which will work for lots of users everywhere, with lots of different Windows settings.

                    What I did was to create a function to call UI.openURL, and then if it fails use ShellExecute with the NULL verb. This seems to work.
                    (I'm not sure why I call openURL first - just to be friendly to the SketchUp Ruby API I guess)

                    
                    	def launch_file(sfile)
                    		trace("Launch; %s", sfile)
                    		# Try SketchUp call first
                    		if (UI.openURL(sfile))
                    			return
                    		end#if
                    		# try shell_execute if openURL fails
                    		shell_execute(sfile)
                    
                    		require 'Win32API'
                    		shell = Win32API.new("shell32","ShellExecute", ['L','P','P','P','P','L'], 'L' )
                    		#shell.call(handle, verb, file, params, folder, showCmd)
                    		iret = shell.call(0, 0, sfile, 0, 0, 1)		
                    		if (iret == 42)
                    			return true
                    		end#if
                    		do_error("Cannot Open file; '%s' - return value; %s", sfile, iret)
                    		return(false)
                    	end#def	
                    
                    

                    Al Hart

                    http:wiki.renderplus.comimageseefRender_plus_colored30x30%29.PNG
                    IRender nXt from Render Plus

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement