What do you mean by “in register”?
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem
What do you mean by “in register”?
How To Ask Questions The Smart Way. 2004
Be precise and informative about your problem
thank you for reply i mean regitry keys like same Registry ("HKEY_CURRENT_USER\Software\
to read a "string" from registry key: (replace w/ your registry/key names at below codes)
#import "Advapi32.dll" int RegOpenKeyExW(uint,string,int,int,int&); int RegQueryValueExW(uint,string,int,int&,uchar&[],int&); int RegSetValueExW(uint,string,int,int,string,int); int RegCloseKey(int); #import uchar rgValue[1024]; int KEY_QUERY_VALUE=0x0001,ERROR_SUCCESS=0,hKey=0; uint HKEY_CURRENT_USER=0x80000001; string subKey="SOFTWARE\\QtProject\\OrganizationDefaults\\FileDialog"; int res=RegOpenKeyExW(HKEY_CURRENT_USER,subKey,0,KEY_QUERY_VALUE,hKey); if(res==ERROR_SUCCESS) { int sz=1024,type=0; RegQueryValueExW(hKey,"lastVisited",0,type,rgValue,sz); RegCloseKey(hKey); ushort usArr[];//convert uchar to ushort-based unicode array ArrayResize(usArr,ArraySize(rgValue)/2); for(int ii=0; ii<ArraySize(rgValue); ii+=2) { if(ii!=ArraySize(rgValue)-1) usArr[ii/2]=rgValue[ii]+16*rgValue[ii+1]; } string rgStr=ShortArrayToString(usArr); Print("string read from registry: ",rgStr); }
to write a "string" to registry key: (replace w/ your registry/key names at below codes)
#import "Advapi32.dll" int RegOpenKeyExW(uint,string,int,int,int&); int RegQueryValueExW(uint,string,int,int&,uchar&[],int&); int RegSetValueExW(uint,string,int,int,string,int); int RegCloseKey(int); #import int KEY_SET_VALUE=0x0002,ERROR_SUCCESS=0,hKey=0; uint HKEY_CURRENT_USER=0x80000001; string subKey="SOFTWARE\\QtProject\\OrganizationDefaults\\FileDialog"; int res=RegOpenKeyExW(HKEY_CURRENT_USER,subKey,0,KEY_SET_VALUE,hKey); if(res==ERROR_SUCCESS) { int REG_SZ=1; string wrStr="file:///D:/"; RegSetValueExW(hKey,"lastVisited",0,REG_SZ,wrStr,StringLen(wrStr)*2); RegCloseKey(hKey); Print("string saved to registry: ",wrStr); }
please kindly note above codes are ONLY tested and validated at mt4 - ie 32-bit app.
if you want to port over mt5, ie 64-bit app, above win32 api calls might need to watch out certain "int vs long" migration.
to read a "string" from registry key: (replace w/ your registry/key names at below codes)
to write a "string" to registry key: (replace w/ your registry/key names at below codes)
please kindly note above codes are ONLY tested and validated at mt4 - ie 32-bit app.
if you want to port over mt5, ie 64-bit app, above win32 api calls might need to watch out certain "int vs long" migration.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello
please anyone can give me the code mq4 for how i and save value in register and read it
thank you before