GetComputerNameA from Windows DLL in MQL5

To add comments, please log in or register
Daniel Arges
202
Daniel Arges  

I just got the code for MQL4, and it is not working for 5.

Any clue?

Tks

Marco vd Heijden
Moderator
8147
Marco vd Heijden  
What have you tried so far ?
Daniel Arges
202
Daniel Arges  
Marco vd Heijden:
What have you tried so far ?
#import "kernel32.dll" 
int GetComputerNameA(string lpBuffer, string nSize);
#import

string buf="";
int result;
result = GetComputerNameA(buf, StringLen(buf));
Alert(result);
Alert(buf);
liregood
16
liregood  

use the mac address

Keith Watford
Moderator
13906
Keith Watford  

Please do not open 2 topics which could be covered in a single topic.

I have deleted your other topic and moved liregood's reply here.

Koldun Zloy
308
Koldun Zloy  
#import "Kernel32.dll"
  int GetComputerNameA( char& lpBuffer[], uint& lpnSize );
#import

char buffer[250];

void OnStart()
{
   uint size = 250;
   GetComputerNameA( buffer, size );
   
   string computerName = CharArrayToString( buffer );
   
   Print( computerName );
}
#import "Kernel32.dll"
  int GetComputerNameW( short& lpBuffer[], uint& lpnSize );
#import

short buffer[250];

void OnStart()
{
   uint size = 250;
   GetComputerNameW( buffer, size );
   
   string computerName = ShortArrayToString( buffer );
   
   Print( computerName );
}
Daniel Arges
202
Daniel Arges  
Koldun Zloy:

It worked Zloy. Many thanks!!

To add comments, please log in or register