Build 610 and kernell32.dll

 

I used to have a debugger tool for my MT4 that used kernell32.dll which outputed to my DEBUGVIEW.exe window in windows7.

It all worked fine until I upgraded to Build600+

I notice depenencies now when you add the indicator and I wondered if I need to set some paths to tell MT4 where to find the dll ??

Just for the record -

I added kernel.dll to the libraries folder incase but it stil ldid not work ..

the dependencies seem to show lots of dll.s required .. not sure what this indicates though but expanding these lists a red symbol that might mean it is missing ?

//+------------------------------------------------------------------+
//|                                                    zmf_DEBUG.mq4 |

#property copyright "moz"
#property link      "http://www.metaquotes.net"
#property indicator_separate_window
#import "kernel32.dll"
   void OutputDebugStringA(string msg);
#import
  /**
* send information to OutputDebugString() to be viewed and logged
* by SysInternals DebugView (free download from microsoft)
* This is ideal for debugging as an alternative to Print().
* The function will take up to 8 string (or numeric) arguments 
* to be concatenated into one debug message.
*/
void log(
   string s1, 
   string s2="", 
   string s3="", 
   string s4="", 
   string s5="", 
   string s6="", 
   string s7="", 
   string s8=""
)

{
   string out = StringTrimRight(StringConcatenate(
      WindowExpertName(), ".mq4 ", Symbol(), 
      " ", s1, 
      " ", s2, 
      " ", s3, 
      " ", s4, 
      " ", s5, 
      " ", s6, 
      " ", s7, 
      " ", s8
   ));
    OutputDebugStringA(out);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
 log("TEST INIT");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
    log("test deINIT");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   log("Low() = ", Low[1]);
   Print("test print ___LOW = ", Low[1]);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Thanks

 
dasser: outputed to my DEBUGVIEW.exe window in windows7. It all worked fine until I upgraded to Build600+

I notice depenencies now when you add the indicator and I wondered if I need to set some paths to tell MT4 where to find the dll ??

void OutputDebugStringA(string msg);
  1. Use SRC for code. Why have you posted THREE times. Why didn't you edit your original post?
  2. Why haven't you read the big threads. Strings are Unicode in build 600+ and you are calling the ANSI version.
  3. Same call as my code. Fix it and post the update.
 

WHRoeder -

Thank you for your attention to this .

1) I am terribly sorry about doing it, I am not new to MT4 but new to posting .. so did not know I could re edit my post . If I can still do this I will, however I do not see how ( advice appreciated )

(1) Item above has been rectified as per WHRoeders comment.


2) I did read and search for anything DLL but had no success finding my problem . Ok I need to go and do some research on Unicide and ANSI as I do not understand the difference. I used debugview before Build600 and it ran like a charm but did not understand the kernell.dll command other than it exported to Debug view wndow .Any explaination wouldbe appreciated .. or links.

As I understand inuitively ( please correct if you can ):

- 2.1 ) There is some issue with the way build 600 sends a string to kernell .dll versus how build500 did .

- 2.2 ) So the issue appears to be a different format of string: microsoft wants to see Unicode format for UI ( user interfaces ) and the old build must have converted from ANSI,see "A" in command .. ( void OutputDebugStringA(string msg); ) to Unicode. SO if build 600 is already in Unicode I am converting when there is no need because it is in the format that Microsoft understands ?

reference link - http://msdn.microsoft.com/en-us/library/windows/desktop/ff381407%28v=vs.85%29.aspx

3) I will look at your code and breakdown what is missing and report back .

I guess this is good in the way that every problem I get makes me understand programming to a greater depth and thankfully some people spend the time helping those of us who are still learning the basics ..

Thanks again WHRoeder

 

@WHRoeder :

Well I started by

a) reading about different string formats ..

b) going to the code you posted and copied it and tried compiling to see how it performs, correcting some compile errors :

Not sure what has happened but now my MT4 crashes everytime i ty and compile it. I then opened another Indicator that did compile only this afternoon and it also crashes MT4 on a compile command.

This makes no sense as to why the compiler seems to now have this issue ..

Here is my code which gets 0 compile errors but crashes my MT4 .

    #import "kernel32.dll"
    void     OutputDebugStringA(string msg);
    #import
 
 void     Log(string s1,string s2="",string s3="",string s4="",string s5="",
             string s6="",string s7="",string s8="",string s9="",string s10="")
  {
  if(IsDllsAllowed()== True)
     {
      //if(status.chart == CS_LIVE) string out="";
      //else  // Visual or Optimizer
      string out  ;
      out  = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" ";
      out   = out + WindowExpertName()+": "
             +s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
             
      OutputDebugStringA(out);
     }
  }
 

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  // log("TEST INIT");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   //  log("test deINIT");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   // log("Low() = ");
   Print("test print ___LOW = ");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


So my problem deepens ..

Any ideas ?

Thanks:-)

 
Use OutputDebugStringW I suspect.
 

I tried that, it compiles and as soon as it completes compile the MT4 still crashes...

MT4 only started crashing since I copied the above custm indicator .. so not sure why ?

 

Ok here is my updated code but it still is not working .. but it is not crashing .

It seems OutputDebugStringW may not be correct or something else ..

Hard to say as it compiles ok but nothing seen on screen when you run debugview.exe ( downloadable from net )

//
// send information to OutputDebugString() to be viewed and logged by
// SysInternal's DebugView (free download from Microsoft) This is ideal for
// debugging as an alternative to Print(). The function will take up to 10
// strings (or numeric) arguments to be concatenated into one debug message.
// http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
//
         #property indicator_separate_window
         #import "kernel32.dll"
         void     OutputDebugStringW( string msg );
         #import

        


void     Log(string s1,string s2="",string s3="",string s4="",string s5="",
             string s6="",string s7="",string s8="",string s9="",string s10="")
         {
            if(IsDllsAllowed()== True)
               {
                  string out  ;
                  out  = TimeToStr(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" ";
                  out  = WindowExpertName()+": ))"+s1+s2+s3+s4+s5+s6+s7+s8+s9+s10;
            
                  OutputDebugStringW(out);
               }
         }
 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
/*
void  AlertMe(string s1,string s2="",string s3="",string s4="",string s5="",
              string s6="",string s7="",string s8="",string s9="",string s10="")
  {
   Alert(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10);
   Log(s1,s2,s3,s4,s5,s6,s7,s8,s9,s10);
  }
*/
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  log("TEST INIT");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   //  log("test deINIT");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   log("Low() = ");
   Print("test print ___LOW = ");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

works just fine for me but only without filtering

i don't know y if filter terminal.exe it doesn't work

 

You have a typo.

log() is short for MathLog().

 
 
WHRoeder - I cannot see any text to you last reply other than euclid quote
Reason: