Win32 DLL def file question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?S2lk?=

    Win32 DLL def file question

    Hi

    How can we export Win32 dll functions for dynamically LoadLibrary and
    GetProceeAddres s ?

    I see VS MFC DLL project has a def file but Win32 DLL does not have one,
    should we add a def file to VS Win32 DLL project , how can I do that ?

    Thank you .
  • Cholo Lennon

    #2
    Re: Win32 DLL def file question

    Kid wrote:
    Hi
    >
    How can we export Win32 dll functions for dynamically LoadLibrary and
    GetProceeAddres s ?
    >
    I see VS MFC DLL project has a def file but Win32 DLL does not have
    one, should we add a def file to VS Win32 DLL project , how can I do
    that ?
    >
    Thank you .
    There is another method to export functions apart from def file: keyword
    __declspec(dlle xport)




    --
    Cholo Lennon
    Bs.As.
    ARG



    Comment

    • Ben Voigt [C++ MVP]

      #3
      Re: Win32 DLL def file question

      Cholo Lennon wrote:
      Kid wrote:
      >Hi
      >>
      >How can we export Win32 dll functions for dynamically LoadLibrary and
      >GetProceeAddre ss ?
      >>
      >I see VS MFC DLL project has a def file but Win32 DLL does not have
      > one, should we add a def file to VS Win32 DLL project , how can I do
      >that ?
      >>
      >Thank you .
      >
      There is another method to export functions apart from def file:
      keyword __declspec(dlle xport)
      But if you want control over the exported names (no mangling) then you must
      use a .def file.

      Simply specify the file you create under Project Properties -Linker ->
      Input -Module Definition File

      Comment

      • Giovanni Dicanio

        #4
        Re: Win32 DLL def file question

        "Joseph M. Newcomer" <newcomer@floun der.comha scritto nel messaggio
        news:bsdm945u2u clatq424m5q3iml qt1h43ig0@4ax.c om...
        There are several ways to avoid name mangling, including using the
        extern "C"
        declaration in the header files and on the functions themselves.
        Joe: if the function is __stdcall, the function name will be decorated as
        MSDN documentation explains (also in "extern C" case).


        Note that you have to
        use the extern "C" in any case because otherwise the C++ client will
        mangle the names. So
        a .def file is not necessary (I haven't used a .def file since Win16,
        where they were
        mandatory, and I do lots of DLLs where name mangling is suppressed and
        functions are
        exported)
        joe
        >
        On Thu, 7 Aug 2008 09:44:29 -0500, "Ben Voigt [C++ MVP]"
        <rbv@nospam.nos pamwrote:
        >
        >>Cholo Lennon wrote:
        >>Kid wrote:
        >>>Hi
        >>>>
        >>>How can we export Win32 dll functions for dynamically LoadLibrary and
        >>>GetProceeAdd ress ?
        >>>>
        >>>I see VS MFC DLL project has a def file but Win32 DLL does not have
        >>> one, should we add a def file to VS Win32 DLL project , how can I do
        >>>that ?
        >>>>
        >>>Thank you .
        >>>
        >>There is another method to export functions apart from def file:
        >>keyword __declspec(dlle xport)
        >>
        >>But if you want control over the exported names (no mangling) then you
        >>must
        >>use a .def file.
        >>
        >>Simply specify the file you create under Project Properties -Linker ->
        >>Input -Module Definition File
        >>>>
        Joseph M. Newcomer [MVP]
        email: newcomer@flound er.com
        Web: http://www.flounder.com
        MVP Tips: http://www.flounder.com/mvp_tips.htm

        Comment

        • David Connet

          #5
          Re: Win32 DLL def file question

          "Ben Voigt [C++ MVP]" <rbv@nospam.nos pamwrote in
          news:OxLGptJ#IH A.2060@TK2MSFTN GP05.phx.gbl:
          Cholo Lennon wrote:
          >Kid wrote:
          >>Hi
          >>>
          >>How can we export Win32 dll functions for dynamically LoadLibrary
          >>and GetProceeAddres s ?
          >>>
          >>I see VS MFC DLL project has a def file but Win32 DLL does not have
          >> one, should we add a def file to VS Win32 DLL project , how can I
          >> do
          >>that ?
          >>>
          >>Thank you .
          >>
          >There is another method to export functions apart from def file:
          >keyword __declspec(dlle xport)
          >
          But if you want control over the exported names (no mangling) then you
          must use a .def file.
          Not necessarily. Inside my dll cpp file, I have:
          extern "C" __declspec(dlle xport) IMyInterface* GetMyInterface( )
          {
          return new MyInterfaceImpl ();
          }

          No def file in sight. (Well, actually there is - but there are no exports
          in it - I think I just forgot to remove it after using the wizard to
          create the project)

          To get the interface:
          GETMYINTERFACE func = reinterpret_cas t<GETMYINTERFAC E>(GetProcAddre ss
          (m_hDllInst, "GetMyInterface "));

          where GETMYINTERFACE (defined in the header with IMyInterface) is:
          typedef IMyInterface* (*GETMYINTERFAC E)();

          Now, if you want to specifically export a function at a set ordinal (is
          that still possible, or am I just having win16 flashbacks?), you need a
          def file.

          Dave Connet

          Comment

          Working...