Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Argument passing for DLL import in C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Argument passing for DLL import in C++

    I'd like to push ticks from C++ application to NT.
    I'm trying to use dll interface, but I have a problem.
    I use SetUp function ( I know this is optional, but it's just a test), and get this error message.
    "Unable to connect to NinjaTrader(/2161262). Please make sure NinjaTrader is running"

    I use "127.0.0.1" and 36973 for arguments of SetUp function. They are same as default value. I think I'm passing arguments in wrong way. Do you have any idea?

    I use Window7 and Visual Studio2010. I also tried in my laptop(Windows XP, Visual Studio 2005), but same result.


    This is my test code
    Code:
    #include "stdafx.h"
    #include <string>
    #include <windows.h>
    
    using namespace std;
    int _tmain(int argc, _TCHAR* argv[])
    {
     typedef int (__stdcall *NTLast)(string instrument, double price, int size);
     typedef int (__stdcall *NTSetUp)(string host, int port);
     NTLast Last = NULL;
     NTSetUp SetUp = NULL;
    
     HINSTANCE  NTDLL;
     NTDLL = LoadLibrary(L"C:/Windows/System32/NtDirect.dll");
    
     if(NTDLL == NULL)
      return 1;
    
    
     Last = (NTLast)GetProcAddress(NTDLL,"Last");
     SetUp = (NTSetUp) GetProcAddress(NTDLL, "SetUp");
     
     string IP = "127.0.0.1";
     int port = 36973;
     rtn = (SetUp)(IP, port);
     
     rtn = Last("TEST", 1.23, 2);
     
     
     FreeLibrary(NTDLL);
     
     return 0;
    }

    #2
    Welcome to our forums here: is the AT interface in NT under the File menu enabled in your setup?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes. I enabled AT interface and connect to "External data feed"

      Comment


        #4
        Hello,

        Ok, Unfortunately C++ is outside our realm to be able to support. The only thing I could recommend if you are able to setup a quick test app in c# to see if you can get this to connect as a quick test.

        As the issue is in how your calling it in your C++ which I'm unable to assist in or there is something blocking the connection. We can verify this if you setup a quick basic c# app and see if you can get the connection to work on this port.

        Alternatively you can try changing the port number as well.

        As we must make sure the connection is not blocked by firewall software first however I suspect it is not since you ran it on two PC's. But both PC's could have same firewall.

        I look forward to assisting you further.

        Comment


          #5
          I met the same problem , when the argment is string it will be wrong .

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cre8able, Yesterday, 01:16 PM
          3 responses
          11 views
          0 likes
          Last Post cre8able  
          Started by ChartTourist, Today, 08:22 AM
          0 responses
          6 views
          0 likes
          Last Post ChartTourist  
          Started by LiamTwine, Today, 08:10 AM
          0 responses
          2 views
          0 likes
          Last Post LiamTwine  
          Started by Balage0922, Today, 07:38 AM
          0 responses
          5 views
          0 likes
          Last Post Balage0922  
          Started by JoMoon2024, Today, 06:56 AM
          0 responses
          6 views
          0 likes
          Last Post JoMoon2024  
          Working...
          X