a simply question about dlls
-
I need to know how you are declaring the function in vba..... Regards Carlos Antollini. Sonork ID 100.10529 cantollini
After the definition in VC++ i put the following code in vba: Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer I have put it into a simple module, without anything else. So, if you need of information on the code in "C", you could look at my first post. thanks
-
After the definition in VC++ i put the following code in vba: Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer I have put it into a simple module, without anything else. So, if you need of information on the code in "C", you could look at my first post. thanks
Gérald Mercet wrote: Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer Change the Integer by Long... Regards.... Carlos Antollini. Sonork ID 100.10529 cantollini
-
After the definition in VC++ i put the following code in vba: Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer I have put it into a simple module, without anything else. So, if you need of information on the code in "C", you could look at my first post. thanks
I've just noticed you named the function
Maximum
in your C++ file andMaximun
in your VB app. Is this a typo in the post or could it be the root of the problem? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
Gérald Mercet wrote: Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer Change the Integer by Long... Regards.... Carlos Antollini. Sonork ID 100.10529 cantollini
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
-
I've just noticed you named the function
Maximum
in your C++ file andMaximun
in your VB app. Is this a typo in the post or could it be the root of the problem? Joaquín M López Muñoz Telefónica, Investigación y Desarrolloyou were right for the typo, i change it and it brought nothing into the way of no working of my application... have you any other idea because i don't succeed in solving my pb?:confused:
-
you were right for the typo, i change it and it brought nothing into the way of no working of my application... have you any other idea because i don't succeed in solving my pb?:confused:
How are you calling
Maximum
from VBA? From your fist post, seems like you're providing no arguments. This has underwent so many changes that maybe it'd be a good idea to post again the (relevant) code in its current form. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
How are you calling
Maximum
from VBA? From your fist post, seems like you're providing no arguments. This has underwent so many changes that maybe it'd be a good idea to post again the (relevant) code in its current form. Joaquín M López Muñoz Telefónica, Investigación y DesarrolloIn my first post you could see thge following code : Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer In fact, in a vba project linked to an excel workbook, i put this code into a module window. And that's all i do. So, i don't know if answer properly to your question!?! regards
-
In my first post you could see thge following code : Public Declare Function Maximun Lib "D:\essai2\Debug\essai2.dll"(byval a as integer,byval b as integer) as integer In fact, in a vba project linked to an excel workbook, i put this code into a module window. And that's all i do. So, i don't know if answer properly to your question!?! regards
I mean, when you actually invoke the function
Maximum
, how do you do it? Do you actually pass two numbers? Also, your firs posts are probably obsolete by know (for instance, I guess you already corrected theMaximun
/Maximum
typo), so it'd be great if you repost the code in its actual form. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
I mean, when you actually invoke the function
Maximum
, how do you do it? Do you actually pass two numbers? Also, your firs posts are probably obsolete by know (for instance, I guess you already corrected theMaximun
/Maximum
typo), so it'd be great if you repost the code in its actual form. Joaquín M López Muñoz Telefónica, Investigación y DesarrolloOk, i think that when you speak about invoking the function Maximum in VBA, it's to ask me how i use this function into another "sub or function", or how i do the declaration into vba? Because as i said below, i have only written into the module window the code the code you have read ("Public declare...") I didn't use any other function which call this routine, i call it directly from excel. Perhaps it's a mistake? And in excel, i put 2 values into 2 cells, for example, into A1 i put "2", and in A2, "5", so in another cell, i call the function Maximum thanks to the button "fx" in the toolbar. So, do i an error by proceeding like that? thanks for your patience. gerald
-
Ok, i think that when you speak about invoking the function Maximum in VBA, it's to ask me how i use this function into another "sub or function", or how i do the declaration into vba? Because as i said below, i have only written into the module window the code the code you have read ("Public declare...") I didn't use any other function which call this routine, i call it directly from excel. Perhaps it's a mistake? And in excel, i put 2 values into 2 cells, for example, into A1 i put "2", and in A2, "5", so in another cell, i call the function Maximum thanks to the button "fx" in the toolbar. So, do i an error by proceeding like that? thanks for your patience. gerald
thanks for your patience. No problem, we're building one of the most beatiful waterfall-like threads so far here in CP. Well, please post your code (that is, the VBA import code and the C++ part) to see how it looks like now. Little help can be provided without that. As for the means of invokation, in your particular scenario please locate the cursor on the cell where
Maximum
is invoked. At the upper area of Excel, just below the toolbars, you will have to see something like=Maximum(A1;A2)
Otherwise, you're probably calling your function the wrong way. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
thanks for your patience. No problem, we're building one of the most beatiful waterfall-like threads so far here in CP. Well, please post your code (that is, the VBA import code and the C++ part) to see how it looks like now. Little help can be provided without that. As for the means of invokation, in your particular scenario please locate the cursor on the cell where
Maximum
is invoked. At the upper area of Excel, just below the toolbars, you will have to see something like=Maximum(A1;A2)
Otherwise, you're probably calling your function the wrong way. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Ok, as the app i test is for the moment just a test, the following code, called essai2.cpp, have only one function, "Maximum". (I have made sthg simple to learn first the syntax before doing sthg more complex) So: // 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 Maximum(int a,int b) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); int max; if(a
-
Ok, as the app i test is for the moment just a test, the following code, called essai2.cpp, have only one function, "Maximum". (I have made sthg simple to learn first the syntax before doing sthg more complex) So: // 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 Maximum(int a,int b) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); int max; if(a
Replace
extern "C" __declspec(dllexport) int Maximum(int a,int b)
with
extern "C" __declspec(dllexport) int WINAPI Maximum(int a,int b)
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Replace
extern "C" __declspec(dllexport) int Maximum(int a,int b)
with
extern "C" __declspec(dllexport) int WINAPI Maximum(int a,int b)
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
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|
-
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|
Ok, now I think we got it. On the C++ part, leave it all as it is now (i.e., maintain the
WINAPI
thing, please). On the VBA part, replace your declaration with the following:Public Declare Function Maximum Lib "D:\essai2\Debug\essai2.dll" Alias "_Maximum@8" (Byval m1 as long,Byval m2 as long) as long
I've tried it myself and it works, please tell me back if it did for you. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
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|
Et bien? (avec un air d'expectation) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
Et bien? (avec un air d'expectation) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Sorry for this later answer, but in my job i'm not a full-time programmer, so i have others things to do(conference...) So, i tried your solution, and it didn't work at all, so i don't know what is wrong in my code or in sthg extern of the 2 environments. But, for the moment, i will try again checking if i haven't forgotten anything. So, before i will come back just a question, how do you find this solution, and what is this alias? thanks a lot
-
Et bien? (avec un air d'expectation) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
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
-
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
What does "sthg" mean? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
-
What does "sthg" mean? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
sthg=something...
-
Et bien? (avec un air d'expectation) Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Are you here or not? because i'm totally lost...please