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?

    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.
        BrettNinjaTrader Product Management

        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 argusthome, 03-08-2026, 10:06 AM
          0 responses
          68 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          41 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          24 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          27 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          53 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X