while (OS.RegEnumKeyEx (phkResult[0], dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) { String path = KEY + "\\" + lpName.toString (0, lpcName [0]);
while (OS.RegEnumKeyEx (OS.HKEY_CLASSES_ROOT, dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) { String path = lpName.toString (0, lpcName [0]);
public static Program [] getPrograms () {	/* 	* The Windows registry maintains a list of file extensions and their related	* editors. In addition, W2K and XP maintain a list of applications which can	* be used to populate the 'Open As' dialog. 2 articles in MSDN describe this	* mechanism: 'File Associations: Arbitrary File Types' and 'Creating a File	* Association'.	* There does not seem to be an API to retrieve the list of programs in the	* 'Open As' dialog. As a result, on W2K machines and above, we look up the	* registry as described in the articles above. On Win95 and NT machines, we use	* the list of applications registered to one or more file classes.	*/	if (OS.IsWin95) return getFileClassPrograms ();	if ((OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) return getFileClassPrograms ();	String KEY = "Applications";	/* Use the character encoding for the default locale */	TCHAR key = new TCHAR (0, KEY, true);	int [] phkResult = new int [1];	if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {		return  new Program [0];	}	Program [] programs = new Program [128];	/* Use the character encoding for the default locale */	TCHAR lpName = new TCHAR (0, 1024);	int [] lpcName = new int [] {lpName.length ()};	FILETIME ft = new FILETIME ();	int dwIndex = 0, count = 0;	while (OS.RegEnumKeyEx (phkResult[0], dwIndex, lpName, lpcName, null, null, null, ft) != OS.ERROR_NO_MORE_ITEMS) {			String path = KEY + "\\" + lpName.toString (0, lpcName [0]);		lpcName [0] = lpName.length ();		Program program = getProgram (path);		if (program != null) {			if (count == programs.length) {				Program [] newPrograms = new Program [programs.length + 128];				System.arraycopy (programs, 0, newPrograms, 0, programs.length);				programs = newPrograms;			}			programs [count++] = program;		}		dwIndex++;	}	if (count != programs.length) {		Program [] newPrograms = new Program [count];		System.arraycopy (programs, 0, newPrograms, 0, count);		programs = newPrograms;	}	return programs;}