Win32UIEnhancerpublic class Win32UIEnhancer extends Object
Methods Summary |
---|
static java.lang.String | findProgramKey(java.lang.String extension)
if (extension == null)
SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (extension.length() == 0)
return null;
if (extension.charAt(0) != '.")
extension = "." + extension; //$NON-NLS-1$
/* Use the character encoding for the default locale */
TCHAR key = new TCHAR(0, extension, true);
int[] phkResult = new int[1];
if (OS.RegOpenKeyEx(OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
return null;
}
int[] lpcbData = new int[1];
int result = OS.RegQueryValueEx(phkResult[0], null, 0, null, (TCHAR) null,
lpcbData);
if (result == 0) {
TCHAR lpData = new TCHAR(0, lpcbData[0] / TCHAR.sizeof);
result = OS.RegQueryValueEx(phkResult[0], null, 0, null, lpData, lpcbData);
if (result == 0)
return lpData.toString(0, lpData.strlen());
}
OS.RegCloseKey(phkResult[0]);
return null;
| public static org.eclipse.swt.graphics.ImageData | getBigImageData(java.lang.String extension)
String key = findProgramKey(extension);
if (key == null) {
return null;
}
/* Icon */
String DEFAULT_ICON = "\\DefaultIcon"; //$NON-NLS-1$
String iconName = getKeyValue(key + DEFAULT_ICON, true);
if (iconName == null)
iconName = ""; //$NON-NLS-1$
int nIconIndex = 0;
String fileName = iconName;
int index = iconName.indexOf(',");
if (index != -1) {
fileName = iconName.substring(0, index);
String iconIndex = iconName.substring(index + 1, iconName.length()).trim();
try {
nIconIndex = Integer.parseInt(iconIndex);
} catch (NumberFormatException e) {
}
}
/* Use the character encoding for the default locale */
TCHAR lpszFile = new TCHAR(0, fileName, true);
int[] phiconSmall = null, phiconLarge = new int[1];
OS.ExtractIconEx(lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
if (phiconLarge[0] == 0) {
return null;
}
Image image = Image.win32_new(null, SWT.ICON, phiconLarge[0]);
ImageData imageData = image.getImageData();
image.dispose();
return imageData;
| static java.lang.String | getKeyValue(java.lang.String string, boolean expand)
/* Use the character encoding for the default locale */
TCHAR key = new TCHAR(0, string, true);
int[] phkResult = new int[1];
if (OS.RegOpenKeyEx(OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
return null;
}
String result = null;
int[] lpcbData = new int[1];
if (OS.RegQueryValueEx(phkResult[0], (TCHAR) null, 0, null, (TCHAR) null,
lpcbData) == 0) {
result = "";
int length = lpcbData[0] / TCHAR.sizeof;
if (length != 0) {
/* Use the character encoding for the default locale */
TCHAR lpData = new TCHAR(0, length);
if (OS.RegQueryValueEx(phkResult[0], null, 0, null, lpData, lpcbData) == 0) {
if (!OS.IsWinCE && expand) {
length = OS.ExpandEnvironmentStrings(lpData, null, 0);
if (length != 0) {
TCHAR lpDst = new TCHAR(0, length);
OS.ExpandEnvironmentStrings(lpData, lpDst, length);
result = lpDst.toString(0, Math.max(0, length - 1));
}
} else {
length = Math.max(0, lpData.length() - 1);
result = lpData.toString(0, length);
}
}
}
}
if (phkResult[0] != 0)
OS.RegCloseKey(phkResult[0]);
return result;
|
|