Serving the Quantitative Finance Community

 
User avatar
opti999
Topic Author
Posts: 0
Joined: October 8th, 2003, 1:09 pm

DLL - who called the function?

December 13th, 2004, 12:06 pm

can anyone tell me ... if I create an MFC DLL in C/C++, is there a way to determine which application is calling a given dll function?e.g. double _stdcall samplefunction(){if application calling this function = "a" then return 1else if application calling this function = "b" then return 2return 3}
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

December 13th, 2004, 12:35 pm

Have you looked at GetStartupInfo () ?The lpTitle field should do nearly[/i[] what you want.
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

December 13th, 2004, 12:37 pm

GetModuleFileName(-1, yourBuffer, sizeOfYourBuffer) returns the path to the EXE loading your DLL.
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

December 13th, 2004, 12:37 pm

Sorry
Last edited by jens on December 12th, 2004, 11:00 pm, edited 1 time in total.
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

December 13th, 2004, 12:37 pm

Sorry I am the only one having problems with the forum?
Last edited by jens on December 12th, 2004, 11:00 pm, edited 1 time in total.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

December 13th, 2004, 2:00 pm

What sort of problem ?
 
User avatar
daveangel
Posts: 5
Joined: October 20th, 2003, 4:05 pm

DLL - who called the function?

December 13th, 2004, 2:09 pm

I think its the old "one post gets you three" problem. Otherwise, I think we got rid of most of our "problems" back in April or May ....
Last edited by daveangel on December 12th, 2004, 11:00 pm, edited 1 time in total.
knowledge comes, wisdom lingers
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

December 13th, 2004, 2:43 pm

Problem? What Problem... Press reply, get an error, hit refresh, get another one, go back, hit replay again.... That makes three posts.And re: the original question: It should be noted that the process can always choose to let the DLL have the wrong information...
 
User avatar
Cuchulainn
Posts: 23029
Joined: July 16th, 2004, 7:38 am

DLL - who called the function?

December 13th, 2004, 3:02 pm

When's the next jamboree?would 20 January be possible?BTW thanks for the greta evening last Thursday.
 
User avatar
daveangel
Posts: 5
Joined: October 20th, 2003, 4:05 pm

DLL - who called the function?

December 13th, 2004, 3:03 pm

No one can accuse Wilmott.com of short-changing you on your posts
knowledge comes, wisdom lingers
 
User avatar
Money
Posts: 2
Joined: September 6th, 2002, 4:00 pm

DLL - who called the function?

January 21st, 2005, 9:08 am

My question is a little different.Let's say I have a Excel Spreadsheet which call a C++ dll (xll) whatever.1) I have the codes for the dll/xll (generated by an analtyic tool)2) The spreadsheet pass some parameters to this dll/xll to compute the option price & greeks.Is there a way for me to debug the .dll via the spreadsheet ?If yes, can u pin down for me exactly the stepsI am using Excel 2000 (Office 2000) and Microsoft VC++ 7.0Cheers mate,Mr. M.
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

DLL - who called the function?

January 21st, 2005, 10:22 am

The best way is to specify the executable in VC++Make sure you use thge full path for the Excel.exe, dir /b /s should do the trick.Doesn't matter which version of Exce you're using because the debugger treats it as just another exe.
 
User avatar
daveangel
Posts: 5
Joined: October 20th, 2003, 4:05 pm

DLL - who called the function?

January 21st, 2005, 12:14 pm

heres a step by step .. I am assuming you are using VC++ 1. build your dll in debug mode2. from the VC IDE, go to Project|Settings and select the Debug tab. In the Executable box click on the right arrow and browse to where your Excel executable is (usually C:\Program Files\Microsoft Office\Office) and select the EXCEL.EXE. OK all the way back.3. Now press F5 (to start the debugger) this will launch EXCEL and then from there on load your dll as usual and your excel sheets as usual. Now set a few break points where you want to stop.HTH
knowledge comes, wisdom lingers
 
User avatar
Money
Posts: 2
Joined: September 6th, 2002, 4:00 pm

DLL - who called the function?

January 22nd, 2005, 2:22 am

thanks mate, will try it on Monday...
 
User avatar
domilar04
Posts: 0
Joined: October 14th, 2004, 6:04 am

DLL - who called the function?

April 5th, 2005, 4:46 am

Hi, I am using VC++.Net now. After selecting EXCEL.EXE as the excutable file and press F5, there is an error message:No symbolic Information'EXCEL.EXE' does not contain debugging information. (No symbols loaded) Click OK to debug anyway. If I click OK, it will generate a new workbook for me. My knowledge about VC.Net is limited. Currently I wanna code in C++ and call dll from VBA.My code in VC++:EXTERN_C void WINAPI MyFunction (LPSAFEARRAY* Array1, LPSAFEARRAY* Array2, double a, double &output ) { ... }Function declared in VBA:Declare Sub MyFunction Lib "MyPath\Debug\MyProject.dll" _ (array1(), array2(), ByVal a As Double, ByRef output As Double)I have built the solution, so I can find "MyProject.dll" under "Debug" folder. But I can't run MyFunction in VBA and can't debug it through VBA. Any guidance?Chris