enumRegValue
Syntax
- int enumRegValue(int index, lpsz szValueName, int maxValueNameLen, int *piType, int *pcbData)
Arguments
- index
- is the zero-based index for the next value name to be retrieved
- szValueName
- is a character string buffer to receive the value name
- maxValueNameLen
- is the size of the szValueName buffer in bytes (including room for the terminating null character)
- piType
- is the address of an int variable which will receive a code indicating the type of data associated with this value (REG_DWORD for 32-bit integer data, REG_SZ for character string data, REG_BINARY for byte sequence data)
- pcbData
- is the address of an int variable which will receive the size in bytes of the data associated with this value
Return
- Returns ERROR_SUCCESS if the operation was successful, otherwise it returns one of the following integer error codes:
ERROR_SUCCESS | (==0) no error |
ERROR_FILE_NOT_FOUND | key or value name not found |
ERROR_MORE_DATA | buffer wasn't big enough (e.g., getRegString, getRegData) |
ERROR_NO_MORE_ITEMS | index >= # of values or subkeys (enumRegValue, enumRegSubKey) |
ERROR_INVALID_FUNCTION | bad top-level key, etc |
ERROR_INVALID_DATA | wrong data type or size (or size > 2048) |
ERROR_BADDB | registry database is corrupt |
ERROR_BADKEY | registry key is invalid |
ERROR_CANTOPEN | registry key could not be opened |
ERROR_CANTREAD | registry key could not be read |
ERROR_CANTWRITE | registry key could not be written |
ERROR_REGISTRY_CORRUPT | registry is corrupt |
ERROR_REGISTRY_IO_FAILED | input/output to registry failed |
ERROR_KEY_DELETED | Illegal operation attempted on a Registry key which has been marked for deletion. |
ERROR_KEY_HAS_CHILDREN | cannot delete a key with subkeys (Windows NT) |
Description
- Enumerates the names of all values stored under the current key.
Example
// fetches installed fonts from the registry and loads them into a combobox
// (modified example, original by Alex Hunter)
%fml
ctl[0]: combobox,"Style 1\nStyle 2\nStyle 3",pos=(*,10),size=(99,50),val=0,Action=PREVIEW
ctl[1]: pushbutton, "Populate Font List", size=(80,15), pos=(*,35)
int iRetVal;
int iDataType;
int iDataLen;
OnCtl(n):{
if (n==1 && e== FME_CLICKED){
setCtlText(0, ""); //clear the ComboBox control
getRegPath(str9, 256); //save current registry path
Info("path=%s",str9);
setRegRoot(HKEY_LOCAL_MACHINE);
setRegPath("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
getRegPath(str0, 256); //save current registry path
Info("path=%s",str0);
for (i=0, iRetVal=ERROR_SUCCESS; iRetVal == ERROR_SUCCESS; i++) {
iRetVal = enumRegValue(i, str0, 256,&iDataType, &iDataLen);
if (i<21){Info("i=%i, iRetVal=%i,value=%s",i,iRetVal,str0);}
if (iRetVal == ERROR_SUCCESS) {
setCtlItemText(0,i,str0);
}
}
setRegPath(str9); //restore registry path to original value
}
return false;
}
Also see
- getRegRoot, setRegRoot, getRegPath, setRegPath