* on error
* @return String or null
*/
public static String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException
{
Advapi32 advapi32;
IntByReference pType, lpcbData;
byte[] lpData = new byte[1];
int handle = 0;
String ret = null;
advapi32 = Advapi32.INSTANCE;
pType = new IntByReference();
lpcbData = new IntByReference();
handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);
if (handle != 0)
{
if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA)
{
lpData = new byte[lpcbData.getValue()];
if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS)
{
ret = convertBufferToString(lpData);
}
}
advapi32.RegCloseKey(handle);
}
return (ret);
}