banner



How To Register An Activex Dll

  • Remove From My Forums

 locked

How to register pro-grammatically an activex dll with admin rights in c++?

  • Question

  • How-do-you-do,

    How to register pro-grammatically an activex dll with admin rights in c++?

    Thanks

Answers

  • Hi,

    How to annals pro-grammatically an activex dll with admin rights in c++?

    Thanks

    A COM (ActiveX) dll exports 2 functions -   DllRegisterServer (registers the COM server ) and   DllUnregisterServer (unregisters the server). The code for these functions is provided by the author of the dll.

    Then from a plan running with elevated privilege (started from an elevated command prompt, or by ShellExecute with "runas", or elevated through it's manifest) the program would utilize LoadLibrary to load the  COM dll, obtain the desired registration function using GetProcAddress and then call the function.


    • Edited by Thursday, June xiv, 2018 11:twenty AM
    • Proposed as reply past Baron Bi Wednesday, June twenty, 2018 8:07 AM
    • Marked as respond by sgrm123 Wed, June 20, 2018 8:54 AM
  • The only thing that y'all may have to practice is use the correct version of regsvr32 depending on the bitness of the server that you lot are registering. The affair to remember is that you should know the motorcar that the server is compiled for before you register information technology.

    If it is a 64 fleck version of Windows, and yous want to annals a 64 bit server, then yous should use C:\Windows\System32\regsvr32.exe, if you lot desire to annals a 32 bit server then you should use C:\Windows\SysWow64\regsvr32.exe.

    It may automatically run the right version if yous employ the incorrect version, but this is the simply possible thing y'all need to do.

    As for where you need to place the server, regedit itself says it best:

    This is Microsoft's ain product too.


    This is a signature. Any samples given are non meant to have error checking or prove best practices. They are meant to just illustrate a point. I may also give inefficient lawmaking or introduce some problems to discourage copy/paste coding. This is considering the major point of my posts is to aid in the learning process.

    • Marked as answer by sgrm123 Wednesday, June 20, 2018 8:54 AM
  • In my experience ShellExecute when called from a 32 bit application will properly start 64 bit executable and that when called from a 64 bit awarding it will properly start a 32 bit executable.  However, I haven't tested this on all versions of Windows.

    To add to Darran Rowe's observation about regsvr32.exe -

    The regsvr32.exe simply loads the COM dll and calls the DllRegisterServer or DllUnregisterServer entry points.

    You can debug a COM server's registration functons in a Visual Studio Dll project for a COM server past setting regsvr32.exe as the target programme to be executed, and passing your COM dll name as an argument.  Fix a breakpoint in your registration code.  Information technology will exist hit after regsvr32.exe loads the dll and calls one of the above entry points.

    Of course the same holds truthful for any programme that loads the COM dll and calls the registration entry points.

    As far as location is concerned, I would definitely non identify any application dlls (or exes) in the organisation folders.  Microsoft guidelines tell us that executables should be located in a subfolder of Programme Files or Program Files(x86) so that they are properly protected with the advisable security since not-administrative users do not take write access to these folders.  Typically, you lot would use an installer for this purpose.

    • Proposed as respond by Baron Bi Midweek, June 20, 2018 8:08 AM
    • Marked equally answer past sgrm123 Wed, June xx, 2018 eight:54 AM
  • I demand one description.

    In my exe I am calling shellexecute with runas .

    If my exe is running with unelevated priviledge whether shellexecute with runas register the dll?

    ShellExecute doesn't register a COM dll.

    The awarding started by ShellExecute does the registration.

    You use runas to tell ShellExecute that you want the application to exist started to run with elevated privilege.

    For example, you could utilize ShellExecute to start regsvr32.exe using runas so that regsvr32.exe runs with elevated privilige to enable COM registration in the HKLM registry keys.  Without elevated privilege attempts to register COM dlls in HKLM will fail with admission denied errors.

    • Marked every bit answer by sgrm123 Midweek, June 20, 2018 8:55 AM
  • I think we have lost track of the original question.

    To sgrm123, are you lot asking "how can I elevate my process and so that I may register a COM server", or are you asking "how can I annals my COM server and so that it gets admin privileges when it is called?"  Anybody has been bold the first question.  If that's what you wanted, then you lot may ignore the residue of this message.

    The answer to the 2d question is "not possible."  An in-process COM server cannot gain administrative privileges.  There's nothing in the registration that remembers or requests privilege.  It gets any privileges the calling awarding has.


    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    • Marked as answer by sgrm123 Wednesday, June 20, 2018 8:55 AM

How To Register An Activex Dll,

Source: https://social.msdn.microsoft.com/Forums/en-US/87b84081-68fc-4500-baa7-24a81ef5d9c5/how-to-register-programmatically-an-activex-dll-with-admin-rights-in-c

Posted by: wittyandeed.blogspot.com

0 Response to "How To Register An Activex Dll"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel