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. a simply question about dlls

a simply question about dlls

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
35 Posts 3 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.
  • G Gerald Mercet

    just for information the C++ code and vba code: //////VBA////////////////////////////////////////////////// Public Declare Function Maximum Lib "D:\essai2\Release\essai2.dll" Alias "_Maximum@8" (ByVal m1 As Long, ByVal m2 As Long) As Long Function test2(m As Long, n As Long) test2 = Maximum(m, n) If test2 = "" Then test2 = 0 Else test2 = test2 End If End Function Sub test22() Cells(5, 5) = Maximum(2, 6) //////C++///////////////////////////////////////////////// / essai2.cpp : Defines the initialization routines for the DLL. // #include "stdafx.h" #include "essai2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // // Note! // // If this DLL is dynamically linked against the MFC // DLLs, any functions exported from this DLL which // call into MFC must have the AFX_MANAGE_STATE macro // added at the very beginning of the function. // // For example: // // extern "C" BOOL PASCAL EXPORT ExportedFunction() // { // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // // normal function body here // } // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that // it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. // // Please see MFC Technical Notes 33 and 58 for additional // details. // ///////////////////////////////////////////////////////////////////////////// // CEssai2App BEGIN_MESSAGE_MAP(CEssai2App, CWinApp) //{{AFX_MSG_MAP(CEssai2App) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEssai2App construction CEssai2App::CEssai2App() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CEssai2App object CEssai2App theApp; extern "C" __declspec(dllexport) int WINAPI Maximum(int a,int b) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); int max; if(a

    J Offline
    J Offline
    Joaquin M Lopez Munoz
    wrote on last edited by
    #26

    What does "sthg" mean? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

    G 1 Reply Last reply
    0
    • J Joaquin M Lopez Munoz

      What does "sthg" mean? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      G Offline
      G Offline
      Gerald Mercet
      wrote on last edited by
      #27

      sthg=something...

      1 Reply Last reply
      0
      • J Joaquin M Lopez Munoz

        Et bien? (avec un air d'expectation) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        G Offline
        G Offline
        Gerald Mercet
        wrote on last edited by
        #28

        Are you here or not? because i'm totally lost...please

        J 2 Replies Last reply
        0
        • G Gerald Mercet

          Are you here or not? because i'm totally lost...please

          J Offline
          J Offline
          Joaquin M Lopez Munoz
          wrote on last edited by
          #29

          I posted a message to you directly by email, but it must have gotten lost in its way to your address... Well, your code seems fine to me. As I was saying in that email, if you can afford sending me the whole stuff by email (the MFC project and the Excel sheet), I'll take a look at it this afternoon. Apart from this, you'd be probably better off trying to obtain the help of someone near you with some expertise in this area. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          G 1 Reply Last reply
          0
          • J Joaquin M Lopez Munoz

            I posted a message to you directly by email, but it must have gotten lost in its way to your address... Well, your code seems fine to me. As I was saying in that email, if you can afford sending me the whole stuff by email (the MFC project and the Excel sheet), I'll take a look at it this afternoon. Apart from this, you'd be probably better off trying to obtain the help of someone near you with some expertise in this area. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

            G Offline
            G Offline
            Gerald Mercet
            wrote on last edited by
            #30

            i've found the solution in the vba references, in fact, in this dialog box i have flagged some specifics option as vc++ debug... and it works now, with exactly the code you submitted me before. So... Now, i could really thank you for your patience. regards gerald:)

            1 Reply Last reply
            0
            • G Gerald Mercet

              Are you here or not? because i'm totally lost...please

              J Offline
              J Offline
              Joaquin M Lopez Munoz
              wrote on last edited by
              #31

              Would you be so kind as to passing me that VBA reference you're talking about? I'd like to learn something from this thread also :) Congratulations and good luck with your project. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

              1 Reply Last reply
              0
              • G Gerald Mercet

                i've done it and it doesn't work yet. What do you think about my way of doing for this dll application perhaps i've forgotten sthg in the procedure? i think that sthg completly stupid have been forgotten, but i don't know what! thanks

                C Offline
                C Offline
                Carlos Antollini
                wrote on last edited by
                #32

                Gerald, please send me your code... Regards Carlos Antollini. Sonork ID 100.10529 cantollini

                1 Reply Last reply
                0
                • G Gerald Mercet

                  I have tried your suggestion without any success. so in the vba code i've done a simple Sub, which only call the function Maximum and put the result into a excel's cell, as following: /////////////////////////////////////////////////////////// Sub test22() Cells(5, 5) = Maximum(2, 6) End Sub ////////////////////////////////////////////////////////// when i play it, i have the following error message: (sorry but as my excel version is french, the error message is in english) so: "Entry point" Maximum of a dll which cannot be found in D:\essai2\Debug\essai2.dll. Of course after this message, i have checked if the path was correct, and it was!!! so, do you think that i'm unlucky X| X| X|

                  C Offline
                  C Offline
                  Carlos Antollini
                  wrote on last edited by
                  #33

                  Gérald Mercet wrote: "Entry point" Maximum of a dll which cannot be found in D:\essai2\Debug\essai2.dll. THAT IS YOUR PROBLEM... VB is a little fastidious for find functions in a dll....;) You need to declare the EXPORT in the .def file

                  EXPORTS
                  @10 Maximum //I put @10, you can put every value

                  Include the .def file in your project and ready. Regards :-D Carlos Antollini. Sonork ID 100.10529 cantollini

                  G 1 Reply Last reply
                  0
                  • C Carlos Antollini

                    Gérald Mercet wrote: "Entry point" Maximum of a dll which cannot be found in D:\essai2\Debug\essai2.dll. THAT IS YOUR PROBLEM... VB is a little fastidious for find functions in a dll....;) You need to declare the EXPORT in the .def file

                    EXPORTS
                    @10 Maximum //I put @10, you can put every value

                    Include the .def file in your project and ready. Regards :-D Carlos Antollini. Sonork ID 100.10529 cantollini

                    G Offline
                    G Offline
                    Gerald Mercet
                    wrote on last edited by
                    #34

                    as you ask me yesterday, sorry to be late, but when you post it i believe that it wasn't the same hour in my office than in yours! so you could see the following code C++ and VBA, for the moment it works, but perhaps you could think that it needs modifications?!? // essai2.cpp : Defines the initialization routines for the DLL. // #include "stdafx.h" #include "essai2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // // Note! // // If this DLL is dynamically linked against the MFC // DLLs, any functions exported from this DLL which // call into MFC must have the AFX_MANAGE_STATE macro // added at the very beginning of the function. // // For example: // // extern "C" BOOL PASCAL EXPORT ExportedFunction() // { // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // // normal function body here // } // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that // it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. // // Please see MFC Technical Notes 33 and 58 for additional // details. // ///////////////////////////////////////////////////////////////////////////// // CEssai2App BEGIN_MESSAGE_MAP(CEssai2App, CWinApp) //{{AFX_MSG_MAP(CEssai2App) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEssai2App construction CEssai2App::CEssai2App() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CEssai2App object CEssai2App theApp; extern "C" __declspec(dllexport) COleDateTime WINAPI Maximini(COleDateTime a,COleDateTime b) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); COleDateTime max; if(a

                    C 1 Reply Last reply
                    0
                    • G Gerald Mercet

                      as you ask me yesterday, sorry to be late, but when you post it i believe that it wasn't the same hour in my office than in yours! so you could see the following code C++ and VBA, for the moment it works, but perhaps you could think that it needs modifications?!? // essai2.cpp : Defines the initialization routines for the DLL. // #include "stdafx.h" #include "essai2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif // // Note! // // If this DLL is dynamically linked against the MFC // DLLs, any functions exported from this DLL which // call into MFC must have the AFX_MANAGE_STATE macro // added at the very beginning of the function. // // For example: // // extern "C" BOOL PASCAL EXPORT ExportedFunction() // { // AFX_MANAGE_STATE(AfxGetStaticModuleState()); // // normal function body here // } // // It is very important that this macro appear in each // function, prior to any calls into MFC. This means that // it must appear as the first statement within the // function, even before any object variable declarations // as their constructors may generate calls into the MFC // DLL. // // Please see MFC Technical Notes 33 and 58 for additional // details. // ///////////////////////////////////////////////////////////////////////////// // CEssai2App BEGIN_MESSAGE_MAP(CEssai2App, CWinApp) //{{AFX_MSG_MAP(CEssai2App) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CEssai2App construction CEssai2App::CEssai2App() { // TODO: add construction code here, // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CEssai2App object CEssai2App theApp; extern "C" __declspec(dllexport) COleDateTime WINAPI Maximini(COleDateTime a,COleDateTime b) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); COleDateTime max; if(a

                      C Offline
                      C Offline
                      Carlos Antollini
                      wrote on last edited by
                      #35

                      Gérald Mercet wrote: so you could see the following code C++ and VBA, for the moment it works, but perhaps you could think that it needs modifications?!? Because you are declaring the function in this way.. Public Declare Function Maximini Lib "D:\essai2\Debug\essai2.dll" Alias "_Maximini@8" (ByVal m1 As Long, ByVal m2 As Long) As Long If you use a .def file you will can declare the function in the following way: Public Declare Function Maximini Lib "D:\essai2\Debug\essai2.dll" (ByVal m1 As Long, ByVal m2 As Long) As Long If your code works fine, great, but with my way you don't need to look for the internal name in the dll. That is the unique difference... Gérald Mercet wrote: as you ask me yesterday, sorry to be late, but when you post it i believe that it wasn't the same hour in my office than in yours! Not problem: I live in South America, And we have several hours of diffence, and plus I'm in vacation, only I am in CP, because I can't live without CP.:(( Regards... :-D Carlos Antollini. Sonork ID 100.10529 cantollini

                      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