Registry entry updated automatically
Revision 1
I need to change the registry entry value of "AccessVBOM" to '1' when i access excel macro and later updated it to '0' once my job is completed.
I used the below code to set the value.
I can able to set the value to 1 but when i tried to reset the value it not getting updated it is still 1.
Void AccesstoVBAProject(BOOL bAccess)
{
HKEY hKey;
DWORD buffer = bAccess;
unsigned long size = sizeof(DWORD);
CLSID clsid;
int i = 0;
BOOL flag = FALSE;
CString version;
CString subkey = "Software\\Microsoft\\Office\\";
for (i = EXCEL2003; i <= EXCEL2010; i++ )
{
if (SUCCEEDED(CLSIDFromProgID(szExcelProgID[i-1], &clsid)))
{
switch(i)
{
case 1:
version = "11.0";
break;
case 2:
version = "12.0";
break;
case 3:
version = "14.0";
break;
}
version = version + "\\Excel\\Security";
subkey = subkey + version;
break;
}
}
if(RegOpenKeyEx(HKEY_CURRENT_USER, (LPCSTR)subkey, 0, KEY_READ|KEY_SET_VALUE|KEY_CREATE_SUB_KEY|KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
{
if(RegSetValueEx(hKey, TEXT("AccessVBOM"), 0, REG_DWORD, (LPBYTE)&buffer, size) == ERROR_SUCCESS)
{
flag = TRUE;
}
RegCloseKey(hKey);
}
return flag;
}
void GetMacroList()
{
AccesstoVBAProject(TRUE);
----
----
AccesstoVBAProject(FALSE);
}
Posted 7-Oct-12 20:19pm
by
RS.Ratheesh.