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 techgetgame, Yesterday, 11:42 PM
          0 responses
          8 views
          0 likes
          Last Post techgetgame  
          Started by sephichapdson, Yesterday, 11:36 PM
          0 responses
          2 views
          0 likes
          Last Post sephichapdson  
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,613 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Yesterday, 05:56 PM
          0 responses
          10 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          20 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X