Announcement

Collapse
No announcement yet.

Register default program

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Register default program

    For users to be able to set my program as the default program, it needs to be registered as a "default program" and it will appear in the list provided by Run > Default programs.

    I have researched this by web search and examining the registry keys for existing apps that are listed, but so far have been unable to register my app so that it does appear in the list. For example, the code I am currently using looks like:

    Code:
    Registry.SetValue(HKEY_CLASSES_ROOT, ".artis", "", "ArtisBrowser", REG_SZ);
    Registry.CreateKey(HKEY_CLASSES_ROOT, "ArtisBrowser", "NoName", "ArtistScope Web Browser", REG_SZ);
    Registry.CreateKey(HKEY_CLASSES_ROOT, "ArtisBrowser\\DefaultIcon", "", "", REG_SZ);
    Registry.CreateKey(HKEY_CLASSES_ROOT, "ArtisBrowser\\CurVer", "NoName", "2.0.1.17", REG_SZ);
    Registry.CreateKey(HKEY_CLASSES_ROOT, "ArtisBrowser\\shell\\open\\command", "", SessionVar.Expand("%AppFolder%\\ASPSbrowser.exe \"%1\""), REG_SZ);
    Registry.SetValue(HKEY_CLASSES_ROOT, "ArtisBrowser", "InstallDir", SessionVar.Expand("%AppFolder%"), REG_SZ);
    -- for XP users
    Registry.CreateKey(HKEY_CURRENT_USER, "SOFTWARE\\ArtistScope\\ArtisBrowser", "NoName", "", REG_SZ);
    Registry.SetValue(HKEY_CURRENT_USER, "SOFTWARE\\ArtistScope\\ArtisBrowser", "Initialised", "0", REG_DWORD);
    -- for default programs
    Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser", "NoName", "", REG_SZ);
    Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities", "NoName", "", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities", "ApplicationDescription", "Secure browser for copy protected websites.", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities", "ApplicationIcon", SessionVar.Expand("%AppFolder%\\ASPSbrowser.exe,0"), REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities", "ApplicationName", "ArtistScope Web Browser", REG_SZ);
    Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\UrlAssociations", "NoName", "", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\UrlAssociations", "http", "ArtisBrowser.Url.Http", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\UrlAssociations", "https", "ArtisBrowser.Url.Https", REG_SZ);
    Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\FileAssociations", "NoName", "", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\FileAssociations", ".asp", "ArtisBrowser", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\FileAssociations", ".aspx", "ArtisBrowser", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\FileAssociations", ".htm", "ArtisBrowser", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\FileAssociations", ".html", "ArtisBrowser", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\FileAssociations", ".shtml", "ArtisBrowser", REG_SZ);
    Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\Startmenu", "NoName", "", REG_SZ);
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities\\Startmenu", "StartmenuInternet", SessionVar.Expand("%AppFolder%\\ASPSbrowser.exe"), REG_SZ);
    
    Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\RegisteredApplications", "ArtisBrowser", "SOFTWARE\\ArtistScope\\ArtisBrowser\\Capabilities", REG_SZ);
    I am using Windows 7 and it doesn't work. Any idea why not?
    ArtistScope - Copy Protection & DRM Software

  • #2
    Here is an extract from my script that sets the default program... Maybe you can find what you are missing in it.

    Code:
    PFiles = Shell.GetFolder(SHF_PROGRAMFILES);
    DFiles = Shell.GetFolder(SHF_APPLICATIONDATA_COMMON);
       
    if InstallVDFSelected == true then
       
       rkey = ".ws"
       bExist = Registry.DoesKeyExist(HKEY_CLASSES_ROOT,rkey);
       if bExist == false then
          Registry.CreateKey(HKEY_CLASSES_ROOT,rkey);
       end
       Registry.SetValue(HKEY_CLASSES_ROOT,rkey,"","VisualDataFlex.Workspace",REG_SZ);
       
       rkey = "VisualDataFlex.Workspace\\shell\\open\\command"
       bExist = Registry.DoesKeyExist(HKEY_CLASSES_ROOT,rkey);
       if bExist == false then
          Registry.CreateKey(HKEY_CLASSES_ROOT,rkey);
       end
       Registry.SetValue(HKEY_CLASSES_ROOT,rkey,"",'"' .. PFiles .. '\\DataFlex 18.0\\Bin\\WsReg.exe" "%1"',REG_SZ);
    HTH
    Mike

    Comment


    • #3
      I believe that you need to send a SHChangeNotify message to notify Windows that new choices are available, otherwise the "RegisteredApplications" key takes no effect.

      Ulrich

      Comment


      • #4
        Is that possible from the SUF installer? Or does it require a system reboot?

        I tried a reboot and that made no difference. There is something wrong with my registry key. Any ideas?
        Last edited by artistscope; 01-03-2016, 08:49 PM.
        ArtistScope - Copy Protection & DRM Software

        Comment


        • #5
          What I did was I looked at the registry settings on a computer that was set up properly and then used that to know what registry settings I needed to set up in the installation script.

          HTH

          Comment


          • #6
            Originally posted by mcooper View Post
            What I did was I looked at the registry settings on a computer that was set up properly and then used that to know what registry settings I needed to set up in the installation script.
            I already tried this which is how I arrived at my code above. But it's not appearing in the default programs list.
            ArtistScope - Copy Protection & DRM Software

            Comment


            • #7
              I have used this code successfully in the past. It doesn't set up a default handler for internet protocols, so I would first try this out as it is before adding new stuff, and check where/if it stops working as expected.

              Code:
              function File.SetAssociation(sExt, sExe, sIcon, sShort, sLong)
                -- Set the file association for the given file (classic method)
                local sRegKey = sShort..".Document";
                
                Registry.SetValue(HKEY_CLASSES_ROOT, sExt, "", sRegKey);
                Registry.SetValue(HKEY_CLASSES_ROOT, sRegKey, "", sLong);
                Registry.SetValue(HKEY_CLASSES_ROOT, sRegKey.."\\DefaultIcon", "", File.GetShortName(sIcon)..",0");
                Registry.SetValue(HKEY_CLASSES_ROOT, sRegKey.."\\shell\\open\\command", "", "\""..sExe.."\" \"%1\"");
                  
                -- Register in Default Programs
                Registry.SetValue(HKEY_LOCAL_MACHINE, SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%\\Capabilities"),
                   "Application Description", sLong, REG_SZ);
                Registry.SetValue(HKEY_LOCAL_MACHINE, SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%\\Capabilities\\FileAssociations"),
                   sExt, sRegKey, REG_SZ);
                Registry.SetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\RegisteredApplications", SessionVar.Expand("%ProductName%"),
                  SessionVar.Expand("SOFTWARE\\%CompanyName%\\%ProductName%\\Capabilities"), REG_SZ);
              
                -- Notify system that new choices are available
                DLL.CallFunction(SessionVar.Expand("%SystemFolder%\\Shell32.dll"), "SHChangeNotify", "134217728,4099,0,0",
                  DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
                error = Application.GetLastError();
                if (error ~= 0) then
                  SetupData.WriteToLogFile("Error\tSHChangeNotify failed: " .. _tblErrorMessages[error] .. "\r\n", true);
                else
                  SetupData.WriteToLogFile("Success\tFile extension '" .. sExt .. "' associated\r\n", true);
                  -- Allow time for system processes to handle the notification
                  Application.Sleep(1000);
                end
              end
              
              -- set up the variables
              sFileExtension = ".smp"; -- the extension you want to register
              sApplicationPath = SessionVar.Expand("%AppFolder%\\myprogram.exe"); -- application for opening the file
              sIconPath = SessionVar.Expand("%AppFolder%\\myprogram.exe"); -- program or path to icon
              sOneWordDescription = "MyAppFile"; -- this will build "MyAppFile.Document" (sRegKey), the short description in registry
              sLongDescription = "MyApplication Document"; -- the long description
              
              -- call the function to set up the file association
              File.SetAssociation(sFileExtension, sApplicationPath, sIconPath, sOneWordDescription, sLongDescription);
              
              -- Note: don't forget to remove the registry keys during uninstall
              The editor may have inserted unwanted spaces in the middle of the script, please check before copying and pasting.

              Ulrich
              Last edited by Ulrich; 05-05-2021, 01:11 AM. Reason: Removed broken color coding of source

              Comment


              • #8
                I am finally getting around to this. It's been a while.

                Re: DLL.CallFunction(SessionVar.Expand("%SystemFolder% \\Shell32.dll"), "SHChangeNotify", "134217728,4099,0,0",

                What is the significance of "134217728,4099,0,0"?

                Also, my app is 32-bit so on a 64-bit computer do we still call "shell32.dll"?
                ArtistScope - Copy Protection & DRM Software

                Comment


                • #9
                  Re: DLL.CallFunction(SessionVar.Expand("%SystemFolder% \\Shell32.dll"), "SHChangeNotify", "134217728,4099,0,0",

                  What is the significance of "134217728,4099,0,0"
                  ?
                  SHChangeNotify
                  SHCNE_ASSOCCHANGED = 0x08000000 = 134217728

                  SHCNF_DWORD | SHCNF_FLUSH = 0x0003 + 0x1000 = 0x1003 = 4099


                  ​​​Also, my app is 32-bit so on a 64-bit computer do we still call "shell32.dll"?
                  Yes.

                  Ulrich

                  Comment

                  Working...
                  X