My setup program created three keys in the Win 10 registry and I can read them but when I try to change the value of one of them I get an error 5 (lack of access priviledge). My code looks something like:
Subroutine ChkReg() use ifwinty use user32 use advapi32 implicit none Integer(4):: iret, iLen Integer(4):: lret Integer(4):: hKey = 0 character(255):: buff buff = ""C iLen = sizeof(buff) - 1 iret = RegOpenKeyEx (HKEY_CLASSES_ROOT, &"PDC"C, & 0, & KEY_EXECUTE, & ! only key that works LOC(hKey) ) if (iret == ERROR_SUCCESS) Then buff = ""C lret = RegQueryValueEx( hKey, "Data1"C, NULL, NULL, & LOC(buff), iLen ) if (iret /= ERROR_SUCCESS) Then buff = ""C lret = RegQueryValueEx( hKey, "Data1"C, NULL, NULL, & LOC(buff), iLen ) iret = MessageBox(NULL, buff, "Data1 Register PDC2", IDOK) else iret = MessageBox(NULL, buff, "Data1 Register PDC1", IDOK) end if Buff = "123456789"C iLen = 10 iret = RegSetValueEX ( hKey, "Data1"C, 0, REG_SZ, LOC(Buff), iLen) iret = RegCloseKey(hKey) End If End Subroutine ChkReg
All works well except the RegSetValueEX which returns an error code of 5. If I try a key of KEY_ALL_ACCESS then I get an error code 5 in RegOpenKeyEx. Any suggestions will be much appreciated.
Thanks,
Brooks