none
How to register a COM dll inWindows 7

    Question

  • when i try to register a COM dll in windows xp...its working......but when i register in windows 7 it throws an error saying "Dll Register Entry Not found"..... Can any help me in finding out the exact way of registering it.....now i am using regsvr32........i tried all combinations of it like /i /n....etc.......
    Sunday, May 16, 2010 11:49 AM

Answers

  • I assume that you have taken the obvious step of making sure you are running as an Administrator?

    COM DLLs are written to HKLM, and since this is a protected resource you must have Administrative access to computer to register. But you also must remember that under Windows Vista and Windows 7 there is User Account Control. What this does is for those people who think they need to run with an Administrative account all the time, it changes it so by default even their security level is that of a regular user. So even if your account is set to be an Administrator, you are getting a token with no more rights than a standard user.

    For you to get it to work in Windows 7. If you are running regsvr32 by hand, you must do it through an elevated command prompt (right click on the command prompt icon and then select Run As Administrator). If you are running it programatically, you have to use ShellExecute(Ex) and use the runas verb. These will prompt you to elevate before trying to register and will run with Administrative rights.


    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://c2kblog.blogspot.com/
    • Marked as answer by dharan06 Tuesday, May 18, 2010 3:17 PM
    Sunday, May 16, 2010 2:09 PM

All replies

  • I assume that you have taken the obvious step of making sure you are running as an Administrator?

    COM DLLs are written to HKLM, and since this is a protected resource you must have Administrative access to computer to register. But you also must remember that under Windows Vista and Windows 7 there is User Account Control. What this does is for those people who think they need to run with an Administrative account all the time, it changes it so by default even their security level is that of a regular user. So even if your account is set to be an Administrator, you are getting a token with no more rights than a standard user.

    For you to get it to work in Windows 7. If you are running regsvr32 by hand, you must do it through an elevated command prompt (right click on the command prompt icon and then select Run As Administrator). If you are running it programatically, you have to use ShellExecute(Ex) and use the runas verb. These will prompt you to elevate before trying to register and will run with Administrative rights.


    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://c2kblog.blogspot.com/
    • Marked as answer by dharan06 Tuesday, May 18, 2010 3:17 PM
    Sunday, May 16, 2010 2:09 PM
  • If the command prompt is not elevated he would be getting registry access error 0x8002801c. I am not sure why the error is  'Dll Register Entry Not found' which indicates 'DllRegisterServer' is not found exported.
    Sunday, May 16, 2010 2:40 PM
  • I agree with you Rajeesh.........but how come the same dll registers successfully in windows XP systems as well as in windows vista(in vista i used admin account)....so is there any other suggestion?....
    Sunday, May 16, 2010 2:44 PM
  • I took the fact that it succeeded on a version of Windows into account and because of that you should know that it is not down to the entrypoint not being found. Or I put it down to crappy programming returning the wrong error. Unless there is a way to tell a DLL that it shouldn't allow a particular version of Windows to see the exports. There is also no way to tell a DLL to not allow it to run on a later version of Windows. You can give a minimum runtime version but not a maximum. So there is nothing which would selectively stop it from working in a later version of Windows.

    The only things which can stop it from successfully registering a server where it succeeded on previous versions are few. One of them is if you have been trying to register a 64 bit server onto a 32 bit machine. This isn't too much of a stretch right now because you never mentioned what platform your Windows XP was (an XP x64 version existed and a Vista x64 version existed). So if you are currently trying to register it on a 32 bit version of Windows 7 then it would explain all of the above. Why it is failing to register and why it is coming up with the entrypoint not found error. The only other option is that it became corrupt when being copied to the machine. But very accurate error messages are the best thing to give, never shorten them, giving them exactly as they are is the best thing you can do.

    So could you give more information on the versions of Windows you have tried it on including your current Windows 7. While you are at it could you give more information on the server itself, including the machine it was built for and what functions are being exported (you can get this from dumpbin).

    If you really want to be daring, you could try manually registering the server. All regsvr32 does when registering a server is the following.

    typedef HRESULT (__stdcall * DRS)(void);
    
    HRESULT MyRegSvr(LPTSTR module)
    {
     HMODULE hm;
     HRESULT hr;
     DRS rs;
    
     hm = LoadLibrary(module);
     if(hm == NULL)
     {
      //output the error message
      return E_FAIL;
     }
    
     rs = (DRS)GetProcAddress(hm, "DllRegisterServer");
     if(rs == NULL)
     {
      //output the error message
      FreeLibrary(hm);
      return E_FAIL;
     }
    
     hr = rs();
     if(FAILED(hr))
     {
      //output the error message
      FreeLibrary(hm);
      return E_FAIL;
     }
    
     FreeLibrary(hm);
     return S_OK;
    }

    So it is a basic load call free. You can try doing that yourself and see if it works.


    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.
    Visit my (not very good) blog at
    http://c2kblog.blogspot.com/
    Sunday, May 16, 2010 4:35 PM
  • There's another thing that could cause registration failure, but I'm not sure that the error message would be "Dll Register Entry Not found". I'm talking about a DLL that the COM DLL depends on and that is missing or cannot be loaded because it doesn't work on Windows 7.

    Windows 7 would be much better without DRM and Product Activation ;) (No, I'm no software pirate)
    Sunday, May 16, 2010 9:31 PM
  • Hi,

    Register the dll with admin priviledge

    1. C:\Windows\System32\cmd.exe(right click -> run as administrator)

    2. regsvr32 <space> path of that dll(eg: e:\dlls\ex.dll)

    3. Click enter key

     

    Try this out

    Thursday, July 01, 2010 6:50 AM
  • Try turning off UAC first. Turn UAC off, log off, log back on, and try to register again.
    Tuesday, December 21, 2010 2:57 PM