来源(null)

/*
 * GetAssociatedExecutable
 *
 * Purpose:  Finds the executable associated with the provided extension
 *
 * Parameters:
 *   lpszExtension   LPSTR points to the extension we're trying to find
 *   an exe for. Does **NO** validation. 
 *
 *   lpszExecutable  LPSTR points to where the exe name will be returned.
 *   No validation here either - pass in 128 char buffer.
 *
 * Return:
 *   BOOL TRUE if we found an exe, FALSE if we didn't.
 *
 */

BOOL FAR PASCAL GetAssociatedExecutable(LPSTR lpszExtension, LPSTR lpszExecutable)  {
	HKEY    hKey;
	LONG    dw;
	LRESULT lRet;
	char    szValue[OLEUI_CCHKEYMAX];
	char    szKey[OLEUI_CCHKEYMAX];
	LPSTR   lpszTemp, lpszExe;
	lRet = RegOpenKey(HKEY_CLASSES_ROOT, NULL, &hKey);
	if (ERROR_SUCCESS != lRet)
		return FALSE;

	dw = OLEUI_CCHPATHMAX;
	lRet = RegQueryValue(hKey, lpszExtension, szValue, &dw);  //ProgId
	if (ERROR_SUCCESS != lRet)    {
		RegCloseKey(hKey);
		return FALSE;
	}

	// szValue now has ProgID
	lstrcpy(szKey, szValue);
	lstrcat(szKey, "\\Shell\\Open\\Command");
	dw = OLEUI_CCHPATHMAX;
	lRet = RegQueryValue(hKey, szKey, szValue, &dw);
	if (ERROR_SUCCESS != lRet)    {
		RegCloseKey(hKey);
		return FALSE;
	}

	// szValue now has an executable name in it.  Let's null-terminate
	// at the first post-executable space (so we don't have cmd line
	// args.
	lpszTemp = szValue;
	while (('\0' != *lpszTemp) && (isspace(*lpszTemp)))
		lpszTemp++;     // Strip off leading spaces
	lpszExe = lpszTemp;
	while (('\0' != *lpszTemp) && (!isspace(*lpszTemp)))
		lpszTemp++;     // Step through exe name
	*lpszTemp = '\0';  // null terminate at first space (or at end).  
	lstrcpy(lpszExecutable, lpszExe);
	return TRUE;
}  

Link: http://www.asm32.net/article_details.aspx?id=87