Working with windows registry through advapi32.dll

 

Hi all

I need too communicate between two or more terminals.

I decide to use registry for this issue.

#define ERROR_SUCCESS 0
#define ERROR_INVALID_PARAMETER 87
#define HKEY_CURRENT_USER 0x80000001
#define HKEY_LOCAL_MACHINE 0x80000002
#define REG_SZ 1
#define REG_BINARY 3
//+------------------------------------------------------------------+
#import "advapi32.dll"
int RegCloseKey(int hKey);
int RegCreateKeyA(int hKey, string lpSubKey, int phkResult);
int RegDeleteValueA(int hKey, string lpValueName);
int RegOpenKeyA(int hKey, string lpSubKey, int phkResult);
int RegQueryValueExA(int hKey, string lpValueName, int lpReserved, int lpType, string lpData, int lpcbData);
int RegSetValueExA(int hKey, string lpValueName, int Reserved, int dwType, string lpData, int cbData);
#import

when I call RegCreateKeyA I receive ERROR_INVALID_PARAMETER 87

I think error is because of converting long parameters to int.

mq4 did not support long data type.

RegCreateKeyA(int hKey, string lpSubKey, int phkResult);

hKey in above api function is a Long parameter and its value is 0x80000001

when I use alert to show this number, it shows a negative number.

What should i do?

int suc = RegOpenKeyA(HKEY_CURRENT_USER, "Test", Ret);
Alert(suc, ", ", Ret);

after calling above code it returns error 87.

please help.






 
I am also interested in working with the registry within mql4. Can anyone help tidicofx with his question and the listed functions from the advapi32.dll?