Author: janderwald
Date: Sun Oct 21 21:11:43 2007
New Revision: 29744
URL:
http://svn.reactos.org/svn/reactos?rev=29744&view=rev
Log:
- use SHGetSpecialFolderPath if used on desktop when creating new file objects
Modified:
trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c
Modified: trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shv_bg_c…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c (original)
+++ trunk/reactos/dll/win32/shell32/shv_bg_cmenu.c Sun Oct 21 21:11:43 2007
@@ -291,23 +291,34 @@
if (!pCurItem)
return;
- if (IShellFolder2_QueryInterface(This->pSFParent, &IID_IPersistFolder2,
(LPVOID*)&psf) != S_OK)
- {
- ERR("Failed to get interface IID_IPersistFolder2\n");
- return;
+ if (This->bDesktop)
+ {
+ if (!SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE))
+ {
+ ERR("Failed to get desktop folder location");
+ return;
+ }
}
- if (IPersistFolder2_GetCurFolder(psf, &pidl) != S_OK)
- {
- ERR("IPersistFolder2_GetCurFolder failed\n");
- return;
+ else
+ {
+ if (IShellFolder2_QueryInterface(This->pSFParent, &IID_IPersistFolder2,
(LPVOID*)&psf) != S_OK)
+ {
+ ERR("Failed to get interface IID_IPersistFolder2\n");
+ return;
+ }
+ if (IPersistFolder2_GetCurFolder(psf, &pidl) != S_OK)
+ {
+ ERR("IPersistFolder2_GetCurFolder failed\n");
+ return;
+ }
+
+ if (IShellFolder2_GetDisplayNameOf(This->pSFParent, pidl, SHGDN_FORPARSING,
&strTemp) != S_OK)
+ {
+ ERR("IShellFolder_GetDisplayNameOf failed\n");
+ return;
+ }
+ StrRetToBufW(strTemp, pidl, szPath, MAX_PATH);
}
-
- if (IShellFolder2_GetDisplayNameOf(This->pSFParent, pidl, SHGDN_FORPARSING,
&strTemp) != S_OK)
- {
- ERR("IShellFolder_GetDisplayNameOf failed\n");
- return;
- }
-
switch(pCurItem->Type)
{
case SHELLNEW_TYPE_COMMAND:
@@ -325,9 +336,7 @@
if (ptr)
{
ptr[1] = 's';
- //StrRetToBufW(strTemp, pidl, szPath, MAX_PATH);
- //TRACE("szPath %s\n", debugstr_w(szPath));
- swprintf(szTemp, szBuffer, strTemp.u.pOleStr);
+ swprintf(szTemp, szBuffer, szPath);
ptr = szTemp;
}
else
@@ -354,17 +363,16 @@
{
i = 2;
- wcscpy(szBuffer, strTemp.u.pOleStr);
- PathAddBackslashW(szBuffer);
- wcscat(szBuffer, szNew);
- wcscat(szBuffer, pCurItem->szDesc);
- wcscpy(szPath, szBuffer);
- wcscat(szPath, pCurItem->szExt);
+ PathAddBackslashW(szPath);
+ wcscat(szPath, szNew);
+ wcscat(szPath, pCurItem->szDesc);
+ wcscpy(szBuffer, szPath);
+ wcscat(szBuffer, pCurItem->szExt);
do
{
- TRACE("FileName %s szBuffer %s i %d \n", debugstr_w(szPath),
debugstr_w(szBuffer), i);
- hFile = CreateFileW(szPath, GENERIC_WRITE, 0, NULL, CREATE_NEW,
FILE_ATTRIBUTE_NORMAL, NULL);
- swprintf(szPath, szFormat, szBuffer, i, pCurItem->szExt);
+ TRACE("FileName %s szBuffer %s i %d \n", debugstr_w(szBuffer),
debugstr_w(szPath), i);
+ hFile = CreateFileW(szBuffer, GENERIC_WRITE, 0, NULL, CREATE_NEW,
FILE_ATTRIBUTE_NORMAL, NULL);
+ swprintf(szBuffer, szFormat, szPath, i, pCurItem->szExt);
i++;
}while(hFile == INVALID_HANDLE_VALUE);