Anyone have an example of C/C++ DLL that's callable from MC?
I have tried to create the most simple c/c++ dll and MC can't find the function in the DLL. It finds the DLL though. But not the entry point for the function. I can call functions in USER32.DLL, so I know it can be done. I am even using the same calling convention for the function, WINAPI, which translates to __stdcall. I am at a total loss on this and wasting precious time. I am about to give up on MC and cancel my subscription (technically MCFX Pro).
hi,
find attached a simple mfcdll project for vs2008 along with an
MC signal called sigdlldemo.
be sure to copy mfcdll.dll into system32 (so that it can be found).
the script loads dll and calls the exported function add.
the result is printed to the mc console (power language editor)
tested with MC 5.0 beta 2
find attached a simple mfcdll project for vs2008 along with an
MC signal called sigdlldemo.
be sure to copy mfcdll.dll into system32 (so that it can be found).
the script loads dll and calls the exported function add.
the result is printed to the mc console (power language editor)
tested with MC 5.0 beta 2
- Attachments
-
- tmp.rar
- (89.43 KiB) Downloaded 270 times
Well I finally got the call to work, but it crashes. I looked at your example but its MFC and I'm using VC++ Express, which doesn't come with MFC.before checking the sample dll, simply look into the script how the DLL
is declard. this probably solves your problem.
it is simply the same as in TS.
Here's how I define my function in my .h file:
Code: Select all
extern "C"
bool __declspec( dllexport ) myfunc(int p);
Code: Select all
bool __declspec( dllexport ) myfunc(int p)
{
return false;
}
If I switch to __stdcall, MultiCharts can't find the entry point for the function. If I use it as I do above, it finds the entry point but crashes upon returning (unwinding the stack).
Clearly it expects a __stdcall, but can't find it if I use that calling convention?
Here is how I declare the function in the script:
Code: Select all
DefineDLLFunc: "mydll.DLL", bool, "myfunc", long;
Here's the crash report:
Code: Select all
<<EXCEPTION>>
Address: 0x6580136C ( 1702892396 )
Code: 0xC0000005 ( -1073741819 )
Continuable: 0x00000000 ( 0 )
Count: 0x00000003 ( 3 )
Description: The instruction at "0x
ErrorCode: 0xC0000005 ( -1073741819 )
ExceptionType: 0x00000000 ( 0 )
Module: C:\Documents and Settings\All Users\Application Data\TS Support\MCFX Pro\StudyServer\Studies\Dlls\Indicators\i_mydll.dll
Process: C:\Program Files\TS Support\MCFX Pro\mcfx.exe
Thread ID: 0x00000E5C ( 3676 )
Time: 14.03.2009 - 22:08:48.654
I finaly got this working. It required a lot of effort in the VC++ project settings, including creating a .def file for exporting the symbols. If anyone wants me to send a sample project that is non-MFC based, let me know.
Thanks to all who lent and hand for support![Smile :)](./images/smilies/icon_smile.gif)
Thanks to all who lent and hand for support
![Smile :)](./images/smilies/icon_smile.gif)
-
- Posts: 407
- Joined: Jan 01 2008
- Been thanked: 3 times
For the less sophisticated programmers out there, "Powerbasic" is a great alternative for creating fast and easy DLL's with MC.
hello,
you need to do more accurate research by your own.
i just googled 1 minute and found a simple dll sample.
attached a simple win32 DLL without MFC (so should be possible
to be built with express eidition)
you need to do more accurate research by your own.
i just googled 1 minute and found a simple dll sample.
attached a simple win32 DLL without MFC (so should be possible
to be built with express eidition)
- Attachments
-
- mcdll.rar
- (8.15 KiB) Downloaded 224 times
-
- mcdll.rar
- simple win32 dll
- (8.15 KiB) Downloaded 231 times
I did a *ton* of research, googled for hours and hours and I didn't find any examples. I'm not sure what you googled for, but no need to question the efforts here. Let's face it the documentation on this subject is not very clear and I shouldn't even have to be writing a DLL to read in a simple file in the first place, it's a little bit 1960's to be doing that with any software platform/API.hello,
you need to do more accurate research by your own.
i just googled 1 minute and found a simple dll sample.
attached a simple win32 DLL without MFC (so should be possible
to be built with express eidition)
And frankly even finding a project sample on its own doesn't answer the question of what makes it work vs. a project you created yourself in VC++ Express.
It turns out that I had some of the compilation options wrong, because they were wrong by default. One of them was that you needed a .Def file, which I had, but which I hadn't specified in the project settings.