Hi, More merging from work done while travelling. Cheers, Jon License: X11 ChangeLog: Jon Griffiths <jon_p_griffiths@yahoo.com> +dlls/shlwapi/shlwapi.spec,dlls/shlwapi/reg.c Implement registry MIME type functions @324-329 ===== "Don't wait for the seas to part, or messiahs to come; Don't you sit around and waste this chance..." - Live jon_p_griffiths@yahoo.com __________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com
diff -u wine/dlls/shlwapi/reg.c wine-develop/dlls/shlwapi/reg.c --- wine/dlls/shlwapi/reg.c Sun Jul 21 12:24:08 2002 +++ wine-develop/dlls/shlwapi/reg.c Fri Sep 6 00:37:15 2002 @@ -34,9 +34,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell); +/* Key/Value names for MIME content types */ static const char *lpszContentTypeA = "Content Type"; static const WCHAR lpszContentTypeW[] = { 'C','o','n','t','e','n','t',' ','T','y','p','e','\0'}; +static const char *szMimeDbContentA = "MIME\\Database\\Content Type\\"; +static const WCHAR szMimeDbContentW[] = { 'M', 'I', 'M','E','\\', + 'D','a','t','a','b','a','s','e','\\','C','o','n','t','e','n','t', + ' ','T','y','p','e','\\', '0' }; +static const DWORD dwLenMimeDbContent = 27; /* strlen of szMimeDbContentA/W */ + +static const char *szExtensionA = "Extension"; +static const WCHAR szExtensionW[] = { 'E', 'x', 't','e','n','s','i','o','n','\0' }; + /* internal structure of what the HUSKEY points to */ typedef struct { HKEY HKCUkey; /* HKEY of opened HKCU key */ @@ -1482,8 +1492,8 @@ TRACE("(hkey=0x%08x,%ld,%s,%p,%p,%p,%p)\n", hKey, dwIndex, debugstr_a(lpszValue), pwLen, pwType, pvData, pcbData); - return RegEnumValueA(hKey, dwIndex, lpszValue, pwLen, NULL, - pwType, pvData, pcbData); + return RegEnumValueA(hKey, dwIndex, lpszValue, pwLen, NULL, + pwType, pvData, pcbData); } /************************************************************************* @@ -1531,7 +1541,7 @@ /************************************************************************* * @ [SHLWAPI.320] * - * Set a content type in the registry. + * Set a MIME content type in the registry. * * PARAMS * hKey [I] Handle to registry key @@ -1580,7 +1590,7 @@ /************************************************************************* * @ [SHLWAPI.322] * - * Delete a content type from the registry. + * Delete a MIME content type from the registry. * * PARAMS * lpszSubKey [I] Name of sub key @@ -1606,6 +1616,170 @@ return ret ? FALSE : TRUE; } +/************************************************************************* + * @ [SHLWAPI.328] + * + * Get the registry path to a MIME content key. + * + * PARAMS + * lpszType [I] Content type to get the path for + * lpszBuffer [O] Destination for path + * dwLen [I] Length of lpszBuffer + * + * RETURNS + * Success: TRUE. lpszBuffer contains the full path. + * Failure: FALSE. + * + * NOTES + * The base path for the key is "MIME\Database\Content Type\" + */ +BOOL SHLWAPI_328(LPCSTR lpszType, LPSTR lpszBuffer, DWORD dwLen) +{ + TRACE("(%s,%p,%ld)\n", debugstr_a(lpszType), lpszBuffer, dwLen); + + if (dwLen > dwLenMimeDbContent && lpszType && lpszBuffer) + { + DWORD dwStrLen = strlen(lpszType); + + if (dwStrLen < dwLen - dwLenMimeDbContent) + { + memcpy(lpszBuffer, szMimeDbContentA, dwLenMimeDbContent); + memcpy(lpszBuffer + dwLenMimeDbContent, lpszType, dwStrLen + 1); + return TRUE; + } + } + return FALSE; +} + +/************************************************************************* + * @ [SHLWAPI.329] + * + * Unicode version of SHLWAPI_328. + */ +BOOL SHLWAPI_329(LPCWSTR lpszType, LPWSTR lpszBuffer, DWORD dwLen) +{ + TRACE("(%s,%p,%ld)\n", debugstr_w(lpszType), lpszBuffer, dwLen); + + if (dwLen > dwLenMimeDbContent && lpszType && lpszBuffer) + { + DWORD dwStrLen = strlenW(lpszType); + + if (dwStrLen < dwLen - dwLenMimeDbContent) + { + memcpy(lpszBuffer, szMimeDbContentA, dwLenMimeDbContent * sizeof(WCHAR)); + memcpy(lpszBuffer + dwLenMimeDbContent, lpszType, (dwStrLen + 1) * sizeof(WCHAR)); + return TRUE; + } + } + return FALSE; +} + +/************************************************************************* + * @ [SHLWAPI.324] + * + * Set the file extension for a MIME content key. + * + * PARAMS + * lpszExt [I] File extension to set + * lpszType [I] Content type to set the extension for + * + * RETURNS + * Success: TRUE. The file extension is set in the registry. + * Failure: FALSE. + */ +BOOL WINAPI SHLWAPI_324(LPCSTR lpszExt, LPCSTR lpszType) +{ + DWORD dwLen; + char szKey[MAX_PATH]; + + TRACE("(%s,%s)\n", debugstr_a(lpszExt), debugstr_a(lpszType)); + + if (!SHLWAPI_328(lpszType, szKey, MAX_PATH)) /* Get full path to the key */ + return FALSE; + + dwLen = strlen(lpszExt) + 1; + + if (SHSetValueA(HKEY_CLASSES_ROOT, szKey, szExtensionA, REG_SZ, lpszExt, dwLen)) + return FALSE; + return TRUE; +} + +/************************************************************************* + * @ [SHLWAPI.325] + * + * Unicode version of SHLWAPI_324. + */ +BOOL WINAPI SHLWAPI_325(LPCWSTR lpszExt, LPCWSTR lpszType) +{ + DWORD dwLen; + WCHAR szKey[MAX_PATH]; + + TRACE("(%s,%s)\n", debugstr_w(lpszExt), debugstr_w(lpszType)); + + /* Get the full path to the key */ + if (!SHLWAPI_329(lpszType, szKey, MAX_PATH)) /* Get full path to the key */ + return FALSE; + + dwLen = (lstrlenW(lpszExt) + 1) * sizeof(WCHAR); + + if (SHSetValueW(HKEY_CLASSES_ROOT, szKey, szExtensionW, REG_SZ, lpszExt, dwLen)) + return FALSE; + return TRUE; +} + +/************************************************************************* + * @ [SHLWAPI.326] + * + * Delete a file extension from a MIME content type. + * + * PARAMS + * lpszType [I] Content type to delete the extension for + * + * RETURNS + * Success: TRUE. The file extension is deleted from the registry. + * Failure: FALSE. The extension may have been removed but the key remains. + * + * NOTES + * If deleting the extension leaves an orphan key, the key is removed also. + */ +BOOL WINAPI SHLWAPI_326(LPCSTR lpszType) +{ + char szKey[MAX_PATH]; + + TRACE("(%s)\n", debugstr_a(lpszType)); + + if (!SHLWAPI_328(lpszType, szKey, MAX_PATH)) /* Get full path to the key */ + return FALSE; + + if (!SHDeleteValueA(HKEY_CLASSES_ROOT, szKey, szExtensionA)) + return FALSE; + + if (!SHDeleteOrphanKeyA(HKEY_CLASSES_ROOT, szKey)) + return FALSE; + return TRUE; +} + +/************************************************************************* + * @ [SHLWAPI.327] + * + * Unicode version of SHLWAPI_326. + */ +BOOL WINAPI SHLWAPI_327(LPCWSTR lpszType) +{ + WCHAR szKey[MAX_PATH]; + + TRACE("(%s)\n", debugstr_w(lpszType)); + + if (!SHLWAPI_329(lpszType, szKey, MAX_PATH)) /* Get full path to the key */ + return FALSE; + + if (!SHDeleteValueW(HKEY_CLASSES_ROOT, szKey, szExtensionW)) + return FALSE; + + if (!SHDeleteOrphanKeyW(HKEY_CLASSES_ROOT, szKey)) + return FALSE; + return TRUE; +} /************************************************************************* * SHRegDuplicateHKey [SHLWAPI.@] diff -u wine/dlls/shlwapi/shlwapi.spec wine-develop/dlls/shlwapi/shlwapi.spec --- wine/dlls/shlwapi/shlwapi.spec Thu Sep 5 22:40:18 2002 +++ wine-develop/dlls/shlwapi/shlwapi.spec Thu Sep 5 23:56:09 2002 @@ -323,12 +323,12 @@ 321 stdcall @(wstr wstr) SHLWAPI_321 322 stdcall @(str) SHLWAPI_322 323 stdcall @(wstr) SHLWAPI_323 -324 stub @ -325 stub @ -326 stub @ -327 stub @ -328 stub @ -329 stub @ +324 stdcall @(str str) SHLWAPI_324 +325 stdcall @(wstr wstr) SHLWAPI_325 +326 stdcall @(str) SHLWAPI_326 +326 stdcall @(wstr) SHLWAPI_327 +328 stdcall @(str ptr long) SHLWAPI_328 +329 stdcall @(wstr ptr long) SHLWAPI_329 330 stub @ 331 stub @ 332 forward @ user32.CallMsgFilterW