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.
        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 schmidtbc16, Today, 03:36 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by RT001, Today, 03:25 PM
          2 responses
          14 views
          0 likes
          Last Post RT001
          by RT001
           
          Started by mbrandau, Today, 01:58 PM
          5 responses
          37 views
          0 likes
          Last Post mbrandau  
          Started by remcovdmeulen, Today, 02:15 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by gbrad, Today, 09:57 AM
          7 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X