NexusFi: Find Your Edge


Home Menu

 





DefineDLLFunc C++ Example


Discussion in EasyLanguage Programming

Updated
    1. trending_up 489 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

DefineDLLFunc C++ Example

(login for full post details)
  #1 (permalink)
TheMetalDog
Tehachapi
 
Posts: 1 since May 2020
Thanks Given: 0
Thanks Received: 0

Hi, I'm trying to create a HelloWorld example c++ project but am getting this error from TS when calling it: "Invalid number of parameters were passed to a user dll function".
I'm not a c++ programmer but a C# programmer creating a wrapper for C# COM.

Here's the code:

------------------------------------------------------------------
The c++ code:
-----------------------------------------------------------------
COMTestingInterop.h:
// COMTESTINGINTEROP.h - Contains declarations of functions
#pragma once

#ifdef COMTESTINGINTEROP_EXPORTS
#define COMTESTINGINTEROP_API __declspec(dllexport)
#else
#define COMTESTINGINTEROP_API __declspec(dllimport)
#endif

extern "C" COMTESTINGINTEROP_API LPSTR hello(LPSTR world);
------------------------------------------------------------------------
ComTestingInterop.cpp:
#include "pch.h"
#include "COMTestingInterop.h"

LPSTR hello(char* world)
{
return LPSTR(world);
}
----------------------------------------------------------------------------------

EasyLanguage:
DefineDLLFunc: "COMTestingInterop.dll",LPSTR,"hello",LPSTR; {World} ;

Vars:
World( "Hey from TS" ) ;

once clearprintlog;
print(hello(World));

--------------------------------------------------------------------------------
If I remove the arguments, and return from the cpp function:
return LPSTR("hello from cpp");
It gets passed back to TS and prints to the log fine. The issue seems to be isolated to being able to add and pass arguments.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
convert tradingview pinescript to ninjascript indicator …
The Elite Circle
Do 5-days or 7-days constitute a Multiweek Channel?
Currencies
Your experience with VPS Ninjamobiletrader ?
Trading Reviews and Vendors
Tradestation historical data to be used in NinjaTrader 8
Platforms and Indicators
TPO letter distribution for E-mini?
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
GFIs1 1 DAX trade per day journal
26 thanks
Big Mike in Ecuador
18 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
11 thanks
King Of The Nasdaq
10 thanks
Sam fired from OpenAI!
9 thanks

(login for full post details)
  #2 (permalink)
WoollyB
RDU, North Carolina
 
Posts: 1 since Mar 2023
Thanks Given: 0
Thanks Received: 0

Hello TheMetalDog,

First, let me say I am making a suggestion without trying. Sorry, but I'm on the road and don't have access to a computer with a compiler.

The signature of your function does not exactly match. LPSTR is Microsoft's "long pointer to a unicode string" if I remember correctly. The "char *" is a pointer to a character. Not identical in the C/C++ domain.


LPSTR hello(LPSTR world)
{
return LPSTR(world);
}

Try that and let me know if it works. Good luck!

Reply With Quote





Last Updated on April 9, 2023


© 2023 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts