Loading ...
Sorry, an error occurred while loading the content.
 

Win32: Visvim bugs

Expand Messages
  • Alexandre Gouraud
    Hi, I have been trying use the Visvim add-in in Visual C++ and had to fix two bugs (I believe they are) to make it work. The first one has already been
    Message 1 of 2 , Apr 11, 2004
      Hi,

      I have been trying use the Visvim add-in in Visual C++
      and had to fix two bugs (I believe they are) to make
      it work.

      The first one has already been mentionned in that
      mailing list. It's the bug about filenames containing
      white spaces. I haven't tried Bram's patch but I tried
      this, and it works (no need to replace '\' by '/'):

      OLECHAR Buf[MAX_OLE_STR];
      char VimCmd[MAX_OLE_STR];
      + char VimTempCmd[MAX_OLE_STR];
      char* VimCmdStart;
      char* s;
      + char* t;

      // Convert all ' ' to '\ '
      + for(s=VimCmd,t=VimTempCmd;*s;++s)
      + {
      + *t=*s;
      + t++;
      + *t=0;
      + }

      + for(s=VimTempCmd+6,t=VimCmd+6;*s;++s)
      + {
      + *t=*s;
      + if(*t==' ')
      + {
      + *t='\\';
      + t++;
      + *t=' ';
      + }
      + t++;
      + }


      The second bug is about registration of the COM
      componant in the registry. This is done in the
      DllRegisterServer() function. The function works if I
      try the add-in with admin rights, but fails if I don't
      have admin rights. More precisely, it is the call to
      _Module.RegisterServer() that fails.

      I have been told that registration is needed only
      once. So once you have installed the component with
      Admin rights, you don't need to call the function
      anymore.

      I solved the problem temporarily using the following
      code in the DllRegisterServer() (Visvim.cpp):

      if(MessageBox(NULL,"Do you want to register
      ?","",MB_YESNO)==IDYES)
      {
      // Registers object, typelib and all interfaces in
      typelib
      hRes = _Module.RegisterServer (TRUE);
      if (FAILED (hRes))
      return hRes;
      }
      else
      {
      return S_OK;
      }


      So answering yes or no when needed would register or
      not the componant. I could at least use the add-in as
      normal user (no special rights).

      A better patch would just look into the registry and
      check if the appropriate key exist or not and try to
      register if the keys does'nt exist. It would return
      S_OK otherwise.

      I would be happy to discuss all of this with anyone
      interessted. I apologize for my very bad english.

      Alexandre.






      Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
      Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

      Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com
    • Bram Moolenaar
      ... I don t know which registry entry to check to verify registering can be skipped. This code looks very unfamiliar to me anyway. I thought of a hack that
      Message 2 of 2 , May 4, 2004
        Alexandre Gourad wrote:

        > The second bug is about registration of the COM
        > componant in the registry. This is done in the
        > DllRegisterServer() function. The function works if I
        > try the add-in with admin rights, but fails if I don't
        > have admin rights. More precisely, it is the call to
        > _Module.RegisterServer() that fails.
        >
        > I have been told that registration is needed only
        > once. So once you have installed the component with
        > Admin rights, you don't need to call the function
        > anymore.
        >
        > I solved the problem temporarily using the following
        > code in the DllRegisterServer() (Visvim.cpp):
        >
        > if(MessageBox(NULL,"Do you want to register
        > ?","",MB_YESNO)==IDYES)
        > {
        > // Registers object, typelib and all interfaces in
        > typelib
        > hRes = _Module.RegisterServer (TRUE);
        > if (FAILED (hRes))
        > return hRes;
        > }
        > else
        > {
        > return S_OK;
        > }
        >
        >
        > So answering yes or no when needed would register or
        > not the componant. I could at least use the add-in as
        > normal user (no special rights).
        >
        > A better patch would just look into the registry and
        > check if the appropriate key exist or not and try to
        > register if the keys does'nt exist. It would return
        > S_OK otherwise.
        >
        > I would be happy to discuss all of this with anyone
        > interessted. I apologize for my very bad english.

        I don't know which registry entry to check to verify registering can be
        skipped. This code looks very unfamiliar to me anyway.

        I thought of a hack that should make it work: Always return S_OK when
        registering is not possible. I'm hoping that something else will fail
        when registering was never done.

        This diff shows my hack solution. Does someone know a better solution?

        *** ../vim-6.2.523/src/VisVim/VisVim.cpp Mon Jan 7 17:16:20 2002
        --- src/VisVim/VisVim.cpp Tue May 4 12:31:29 2004
        ***************
        *** 86,92 ****
        // Registers object, typelib and all interfaces in typelib
        hRes = _Module.RegisterServer (TRUE);
        if (FAILED (hRes))
        ! return hRes;

        _ATL_OBJMAP_ENTRY *pEntry = _Module.m_pObjMap;
        CRegKey key;
        --- 86,97 ----
        // Registers object, typelib and all interfaces in typelib
        hRes = _Module.RegisterServer (TRUE);
        if (FAILED (hRes))
        ! // Hack: When this fails we might be a normal user, while the
        ! // admin already registered the module. Returning S_OK then
        ! // makes it work. When the module was never registered it
        ! // will soon fail in another way.
        ! // old code: return hRes;
        ! return S_OK;

        _ATL_OBJMAP_ENTRY *pEntry = _Module.m_pObjMap;
        CRegKey key;


        --
        hundred-and-one symptoms of being an internet addict:
        96. On Super Bowl Sunday, you followed the score by going to the
        Yahoo main page instead of turning on the TV.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.