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 use exported classes from DLL without using header.

How to use exported classes from DLL without using header.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
8 Posts 5 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.
  • A Offline
    A Offline
    aatul
    wrote on last edited by
    #1

    I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.

    C I A R D 5 Replies Last reply
    0
    • A aatul

      I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Why don't you want to provide header files ? It is always done this way...


      Cédric Moonen Software developer
      Charting control [v1.2]

      1 Reply Last reply
      0
      • A aatul

        I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        As Cedric said, what's so bad about giving headers? One way or another, their code needs to know how to talk to yours, and the secret of all your dodgy function names will be revealed. That said... Some companies I use just distribute the DLLS. I then use #import to get the COM interfaces from those. But that is COM, and Typelibs, and all sorts of fun... Chances are its more headache than its worth, but it does let their DLLS be used from many languages, include VB. *I* don't care about that, but you might. Iain.

        1 Reply Last reply
        0
        • A aatul

          I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.

          A Offline
          A Offline
          aatul
          wrote on last edited by
          #4

          can #pragma comment(lib, "libname.lib") help??

          C 1 Reply Last reply
          0
          • A aatul

            can #pragma comment(lib, "libname.lib") help??

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            That's only to specify that you link to the lib file. You still don't know how the exported classes look like.


            Cédric Moonen Software developer
            Charting control [v1.2]

            1 Reply Last reply
            0
            • A aatul

              I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.

              R Offline
              R Offline
              Rajkumar R
              wrote on last edited by
              #6

              If you don't want the client to use the exported classes directly from the dll, you can. If the client uses the DLL directly, the exposed classes needs to have its declaration exposed right. If you really want to hide the class declaration that might have some implementation exposed, provide only interface exposed to it similar to COM concepts.

              1 Reply Last reply
              0
              • A aatul

                I have written a dll and exported classes. I don't want to give header file to clients. How this can be done. I want only to give lib file and dll to the user.

                D Offline
                D Offline
                dfz
                wrote on last edited by
                #7

                Just a thought (may not work), but if your DLL is simple enough and doesn't require any specific definitions (i.e. structures, macros) maybe this code snippet can help: typedef int (FAR * Func1_Substract)(int, int); HMODULE hMod = LoadLibrary(_T("test.dll")); Func1_Substract substract = reinterpret_cast<Func1_Substract>( ::GetProcAddress(hMod, "dll_substract_function")); int result = substract(10,10);

                I 1 Reply Last reply
                0
                • D dfz

                  Just a thought (may not work), but if your DLL is simple enough and doesn't require any specific definitions (i.e. structures, macros) maybe this code snippet can help: typedef int (FAR * Func1_Substract)(int, int); HMODULE hMod = LoadLibrary(_T("test.dll")); Func1_Substract substract = reinterpret_cast<Func1_Substract>( ::GetProcAddress(hMod, "dll_substract_function")); int result = substract(10,10);

                  I Offline
                  I Offline
                  Iain Clarke Warrior Programmer
                  wrote on last edited by
                  #8

                  This will also need undecorated export functions (ie, created using extern "C" if you're using C++). It's alway far too easy to break, compared to a header file. It should work though, but there are a few gotchas. Iain.

                  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