June 2004
M T W T F S S
« Jun   Nov »
 123456
78910111213
14151617181920
21222324252627
282930  
Chris Donnan

Create Your Badge

Chris Donnan : Programming – Brooklyn Style

software, trading, family, fun

TradeStation platform interoperation – using GlobalVariables
Many folks in the TradeStation community have requested this vanilla functionality. The GlobalVariable.dll is here:
http://www.tradestationsupport.com/discussions/Topic_Archive.aspx?Topic_ID=19622
The C++ source is there as well. Basically - the C++ code allocates a shared memory block and then the GlobalVariable.dll 
is used to put/ get from it - thus sharing between multiple exe's. Have fun. 
-Chris
PS - there is also lots of code/ examples of c++ (win32) and c# interop at TradeStationworld.com search c# and you can 
see all my posts and code.
using System;
using System.Runtime.InteropServices;
namespace TradeStation.Interop
{
public class GlobalVariables
{

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetInteger( int iLocation, int iVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_GetInteger( int iLocation ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetNamedInt( string sIntVarName, int iVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_GetNamedInt( string sIntVarName, int iErrorCode ) ;

[DllImport("GlobalVariable.dll")]
 public static extern int  GV_SetFloat( int iLocation, float fVal ) ;

[DllImport("GlobalVariable.dll")]
 public static extern float  GV_GetFloat( int iLocation ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetNamedFloat( string sFloatVarName, float fVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern float  GV_GetNamedFloat( string sFloatVarName, float fErrorCode ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetDouble( int iLocation, double dVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern double  GV_GetDouble( int iLocation ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetNamedDouble( string sDoubleVarName, double dVal ) ;

[DllImport("GlobalVariable.dll")]
public static extern double  GV_GetNamedDouble( string sDoubleVarName, double dErrorCode ) ;

[DllImport("GlobalVariable.dll")]
public static extern int  GV_SetString( int iLocation, string sVal ) ;

[DllImport("GlobalVariable.dll")]
 public static extern int  GV_SetNamedString( string sStringVarName, string sVal ) ;

[DllImport("GlobalVariable.dll", EntryPoint="GV_GetNamedString")]
static extern IntPtr GetNamedString( string sStringVarName, string sErrorCode ) ;

[DllImport("GlobalVariable.dll", EntryPoint="GV_GetString")]
 static extern IntPtr GetString( int iLocation ) ;

 public static string GV_GetString( int iLocation )
{
IntPtr ptr = GetString(iLocation);
//return Marshal.PtrToStringAuto(ptr);
return Marshal.PtrToStringAnsi(ptr);
}

public static string GV_GetNamedString( string sStringVarName, string sErrorCode )
{
IntPtr ptr = GetNamedString(sStringVarName,sErrorCode);
//return Marshal.PtrToStringAuto(ptr);
return Marshal.PtrToStringAnsi(ptr);
}

}
}

You can leave a response, or trackback from your own site.