Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to register dll or ocx file via c++ code

how to register dll or ocx file via c++ code

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
14 Posts 7 Posters 0 Views 1 Watching
  • 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.
  • B b rad311

    Hello, Does anyone know how to register a dll or ocx file using c++ code (in particular I'm using vc++ 2008 standard)? I need it to work for Vista and Windows 7. Thanks!

    R Offline
    R Offline
    Rajesh R Subramanian
    wrote on last edited by
    #3

    See DLLRegisterServer()[^]

    Workout progress:
    Current arm size: 14.4in
    Desired arm size: 18in
    Next Target: 15.4in by Dec 2010

    Current training method: HIT

    B 1 Reply Last reply
    0
    • A Aescleal

      It's a three step process: - LoadLibrary to get the DLL into memory - GetProcAddress to get the address of the function DllRegisterServer - Call DllRegisterServer through the pointer from GetProcAddress. Or you can just link with the DLL normally and call DllRegisterServer by name. Cheers, Ash

      B Offline
      B Offline
      b rad311
      wrote on last edited by
      #4

      Thanks Ash, Will this work on Vista and Windows 7 with them having the extra security features?

      A 1 Reply Last reply
      0
      • B b rad311

        Thanks Ash, Will this work on Vista and Windows 7 with them having the extra security features?

        A Offline
        A Offline
        Aescleal
        wrote on last edited by
        #5

        I think so, I've done it successfully on both of them. There might have to be some fancy footwork on Vista but if there is my mind's a blank. Oh, I was using it from a setup program which was running elevated under Vista and Windows 7 - which might be a problem. Cheers, Ash

        _ 1 Reply Last reply
        0
        • R Rajesh R Subramanian

          See DLLRegisterServer()[^]

          Workout progress:
          Current arm size: 14.4in
          Desired arm size: 18in
          Next Target: 15.4in by Dec 2010

          Current training method: HIT

          B Offline
          B Offline
          b rad311
          wrote on last edited by
          #6

          Alternatively, can the .ocx file be embedded into the binary??

          _ 1 Reply Last reply
          0
          • A Aescleal

            I think so, I've done it successfully on both of them. There might have to be some fancy footwork on Vista but if there is my mind's a blank. Oh, I was using it from a setup program which was running elevated under Vista and Windows 7 - which might be a problem. Cheers, Ash

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #7

            Registering a DLL/OCX involves modifying the registry which means elevated privileges. You can either always remember to run the registering application as administrator (Right click -> Run as administrator). Or you can instruct the application to always run elevated - Project -> Properties -> Configuration Properties -> Linker -> Manifest File -> UAC Execution Level -> requireAdministrator.

            «_Superman_»
            I love work. It gives me something to do between weekends.

            Microsoft MVP (Visual C++)

            Polymorphism in C

            1 Reply Last reply
            0
            • B b rad311

              Alternatively, can the .ocx file be embedded into the binary??

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #8

              OCX can be embedded in a binary, but this is not an alternate solution. To use the OCX you will have to extract it from the binary and register it.

              «_Superman_»
              I love work. It gives me something to do between weekends.

              Microsoft MVP (Visual C++)

              Polymorphism in C

              1 Reply Last reply
              0
              • B b rad311

                Hello, Does anyone know how to register a dll or ocx file using c++ code (in particular I'm using vc++ 2008 standard)? I need it to work for Vista and Windows 7. Thanks!

                K Offline
                K Offline
                KingsGambit
                wrote on last edited by
                #9

                Following article on Reg-Free COM might be a good read: http://msdn.microsoft.com/en-us/magazine/cc188708.aspx[^]

                1 Reply Last reply
                0
                • B b rad311

                  Hello, Does anyone know how to register a dll or ocx file using c++ code (in particular I'm using vc++ 2008 standard)? I need it to work for Vista and Windows 7. Thanks!

                  S Offline
                  S Offline
                  Shivanand Gupta
                  wrote on last edited by
                  #10

                  ocx control can register with "regsvr32". ther is 3 possiable solution 1. you can put command in command prompt regsrvr32 OcxFilePath or 2. Make batch file and open with c code. batch file contain data regsrvr32 OcxFilePath or 3. open a process with c code with command line argument regsrvr32 OcxFilePath

                  1 Reply Last reply
                  0
                  • A Aescleal

                    It's a three step process: - LoadLibrary to get the DLL into memory - GetProcAddress to get the address of the function DllRegisterServer - Call DllRegisterServer through the pointer from GetProcAddress. Or you can just link with the DLL normally and call DllRegisterServer by name. Cheers, Ash

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #11

                    You should initialise COM too, as the code here[^] shows.

                    Steve

                    A 1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      You should initialise COM too, as the code here[^] shows.

                      Steve

                      A Offline
                      A Offline
                      Aescleal
                      wrote on last edited by
                      #12

                      You're partly right as the original poster mentioned ocxs, mea culpa! However you don't have to initialise COM to load up a DLL and call an exported function on it. You can (conceptually) easily register most COM DLLs by writing to the registry directly - if you know all the details of the objects you're registering (GUIDs of the CoClasses and IIDs of the CoInterfaces). Have a look in "Essential COM" by Don Box for a script based DllRegisterServer that doesn't require COM to be initialised. ActiveX controls may be an exception but they're out of my experience. If that's the case, as they implement OLE interfaces, you need OleInitialise() before registering and NOT CoInitialize(). Cheers, Ash

                      S 1 Reply Last reply
                      0
                      • A Aescleal

                        You're partly right as the original poster mentioned ocxs, mea culpa! However you don't have to initialise COM to load up a DLL and call an exported function on it. You can (conceptually) easily register most COM DLLs by writing to the registry directly - if you know all the details of the objects you're registering (GUIDs of the CoClasses and IIDs of the CoInterfaces). Have a look in "Essential COM" by Don Box for a script based DllRegisterServer that doesn't require COM to be initialised. ActiveX controls may be an exception but they're out of my experience. If that's the case, as they implement OLE interfaces, you need OleInitialise() before registering and NOT CoInitialize(). Cheers, Ash

                        S Offline
                        S Offline
                        Stephen Hewitt
                        wrote on last edited by
                        #13

                        I've read "Essential COM". In the case of the script bases registration code (I can't remember it explicitly) the script runtime almost certainly initialises COM (so it's already done). I understand that LoadLibrary and friends don't require COM, but that's hardly the point. The point is the runtime environment the registration code is allowed to assume.

                        Steve

                        A 1 Reply Last reply
                        0
                        • S Stephen Hewitt

                          I've read "Essential COM". In the case of the script bases registration code (I can't remember it explicitly) the script runtime almost certainly initialises COM (so it's already done). I understand that LoadLibrary and friends don't require COM, but that's hardly the point. The point is the runtime environment the registration code is allowed to assume.

                          Steve

                          A Offline
                          A Offline
                          Aescleal
                          wrote on last edited by
                          #14

                          Your memory's a bit faulty on that one, the code in the book doesn't initialise COM or assume that it's loaded by a process that's already initialised it.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups