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 zstheorist, Today, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          150 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          6 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          6 views
          0 likes
          Last Post tkaboris  
          Working...
          X