What have you tried so far ?
Marco vd Heijden:
What have you tried so far ?
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);
use the mac address
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.
#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 ); }
Koldun Zloy:
It worked Zloy. Many thanks!!
#import "Kernel32.dll" int GetComputerNameW(short& lpBuffer[], uint& lpnSize); int GetComputerNameA(char& lpBuffer[], uint& lpnSize); #import #define MAX_COMPUTERNAME_LENGTH 1024+1 string GetComputerNameW() { ushort buffer[MAX_COMPUTERNAME_LENGTH]; uint size = MAX_COMPUTERNAME_LENGTH-1; GetComputerNameW(buffer, size); string computerName = ShortArrayToString(buffer); return (computerName); } string GetComputerNameA() { uchar buffer[MAX_COMPUTERNAME_LENGTH]; uint size = MAX_COMPUTERNAME_LENGTH-1; GetComputerNameA(buffer, size); string computerName = CharArrayToString(buffer); return (computerName); }
Both these methods work for me. I use the UNICODE version at all times. Dont't try to typedef these.... typedef only works for function pointers in MQL
#import "Secur32.dll" bool GetUserNameExW(int type, string& buffer, int &size); #import string readWinuser() { string pcNameBuffer; int size = 2047; createStringBuffer(pcNameBuffer,size); GetUserNameExW(2, pcNameBuffer, size); return pcNameBuffer; } void createStringBuffer(string& buff, int minLen=1024) { buff = "_"; while(StringLen(buff)<=minLen) { StringAdd(buff,buff); } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I just got the code for MQL4, and it is not working for 5.
Any clue?
Tks