Commit in reactos/lib/shell32 on MAIN
shelllink.c+27-311.18 -> 1.19
Francois Gouget <fgouget@free.fr>
- Make Unicode const strings static so they are not copied to the stack
  each time we enter the function.
Aric Stewart <aric@codeweavers.com>
- In IPersistFile_Save if the exe file is not found, trust the path we
  are given and allow creation of the link.
- Make sure exePath contains the path since it is used later in the
  function as well.
Ge van Geldorp <gvg@reactos.com>
- Match whitespace to winehq

reactos/lib/shell32
shelllink.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- shelllink.c	20 Sep 2004 09:18:52 -0000	1.18
+++ shelllink.c	20 Sep 2004 21:39:04 -0000	1.19
@@ -248,7 +248,7 @@
 
 static BOOL StartLinkProcessor( LPCOLESTR szLink )
 {
-    const WCHAR szFormat[] = {'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
+    static const WCHAR szFormat[] = {'w','i','n','e','m','e','n','u','b','u','i','l','d','e','r','.','e','x','e',
                               ' ','-','r',' ','"','%','s','"',0 };
     LONG len;
     LPWSTR buffer;
@@ -524,7 +524,7 @@
     TRACE("(%p)(%p)\n", This, stm);
 
     if( !stm )
-	return STG_E_INVALIDPOINTER;
+	  return STG_E_INVALIDPOINTER;
 
     dwBytesRead = 0;
     r = IStream_Read(stm, &hdr, sizeof(hdr), &dwBytesRead);
@@ -538,7 +538,7 @@
     if( !IsEqualIID(&hdr.MagicGuid, &CLSID_ShellLink) )
         return E_FAIL;
 
-    if( hdr.dwFlags & SCF_PIDL )
+    /* if( hdr.dwFlags & SCF_PIDL ) */  /* FIXME: seems to always have a PIDL */
     {
         r = ILLoadFromStream( stm, &This->pPidl );
         if( FAILED( r ) )
@@ -580,7 +580,7 @@
         goto end;
 
     if( hdr.dwFlags & SCF_WORKDIR )
-    {
+          {
         r = Stream_LoadString( stm, unicode, &This->sWorkDir );
         TRACE("Working Dir  -> %s\n",debugstr_w(This->sWorkDir));
     }
@@ -676,17 +676,19 @@
     *exePath = '\0';
 
     if (This->sPath)
-	SHELL_FindExecutable(NULL, This->sPath, wOpen, exePath, MAX_PATH, NULL, NULL, NULL, NULL);
-
-    /* if there's no PIDL, generate one */
-    if( ! This->pPidl )
     {
-        if( !*exePath )
-            return E_FAIL;
-
-        This->pPidl = ILCreateFromPathW(exePath);
+        SHELL_FindExecutable(NULL, This->sPath, wOpen, exePath, MAX_PATH, NULL, NULL, NULL, NULL);
+        /*
+         * windows can create lnk files to executables that do not exist yet
+         * so if the executable does not exist the just trust the path they
+         * gave us
+         */
+        if( !*exePath ) strcpyW(exePath,This->sPath);
     }
 
+    /* if there's no PIDL, generate one */
+    if( ! This->pPidl ) This->pPidl = ILCreateFromPathW(exePath);
+
     memset(&header, 0, sizeof(header));
     header.dwSize = sizeof(header);
     memcpy(&header.MagicGuid, &CLSID_ShellLink, sizeof(header.MagicGuid) );
@@ -820,6 +822,7 @@
 	return S_OK;
 }
 
+
 static BOOL SHELL_ExistsFileW(LPCWSTR path)
 {
     HANDLE hfile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
@@ -936,7 +939,7 @@
 /**************************************************************************
  *  IShellLinkA_QueryInterface
  */
-static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid, LPVOID *ppvObj)
+static HRESULT WINAPI IShellLinkA_fnQueryInterface( IShellLinkA * iface, REFIID riid,  LPVOID *ppvObj)
 {
 	IShellLinkImpl *This = (IShellLinkImpl *)iface;
 
@@ -971,7 +974,6 @@
 	TRACE("-- Interface: E_NOINTERFACE\n");
 	return E_NOINTERFACE;
 }
-
 /******************************************************************************
  * IShellLinkA_AddRef
  */
@@ -983,7 +985,6 @@
 
 	return ++(This->ref);
 }
-
 /******************************************************************************
  *	IShellLinkA_Release
  */
@@ -1011,7 +1012,7 @@
         HeapFree(GetProcessHeap(), 0, This->sDescription);
 
     if (This->sPath)
-        HeapFree(GetProcessHeap(), 0, This->sPath);
+        HeapFree(GetProcessHeap(),0,This->sPath);
 
     if (This->pPidl)
         ILFree(This->pPidl);
@@ -1062,8 +1063,7 @@
     TRACE("(%p)->(pidl=%p)\n",This, pidl);
 
     if (This->pPidl)
-        ILFree(This->pPidl);
-
+	ILFree(This->pPidl);
     This->pPidl = ILClone (pidl);
     This->bDirty = TRUE;
 
@@ -1178,14 +1178,14 @@
 
 static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
 {
-    IShellLinkImpl *This = (IShellLinkImpl *)iface;
+	IShellLinkImpl *This = (IShellLinkImpl *)iface;
 
-    TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
+	TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
 
-    This->wHotKey = wHotkey;
-    This->bDirty = TRUE;
+	This->wHotKey = wHotkey;
+	This->bDirty = TRUE;
 
-    return S_OK;
+	return S_OK;
 }
 
 static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
@@ -1232,7 +1232,7 @@
     return hr;
 }
 
-static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath, INT cchIconPath, INT *piIcon)
+static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
 {
     IShellLinkImpl *This = (IShellLinkImpl *)iface;
 
@@ -1280,7 +1280,7 @@
         return E_FAIL;
 }
 
-static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath, INT iIcon)
+static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
 {
     IShellLinkImpl *This = (IShellLinkImpl *)iface;
 
@@ -1306,7 +1306,6 @@
 
     if (This->sPathRel)
         HeapFree(GetProcessHeap(), 0, This->sPathRel);
-
     This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
     This->bDirty = TRUE;
 
@@ -1553,7 +1552,6 @@
                                 (lstrlenW( pszDir )+1)*sizeof (WCHAR) );
     if ( !This->sWorkDir )
         return E_OUTOFMEMORY;
-
     lstrcpyW( This->sWorkDir, pszDir );
     This->bDirty = TRUE;
 
@@ -1586,7 +1584,6 @@
                              (lstrlenW( pszArgs )+1)*sizeof (WCHAR) );
     if ( !This->sArgs )
         return E_OUTOFMEMORY;
-
     lstrcpyW( This->sArgs, pszArgs );
     This->bDirty = TRUE;
 
@@ -1660,7 +1657,7 @@
     return hr;
 }
 
-static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath, INT cchIconPath, INT *piIcon)
+static HRESULT WINAPI IShellLinkW_fnGetIconLocation(IShellLinkW * iface, LPWSTR pszIconPath,INT cchIconPath,INT *piIcon)
 {
     _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
 
@@ -1708,7 +1705,7 @@
         return E_FAIL;
 }
 
-static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath, INT iIcon)
+static HRESULT WINAPI IShellLinkW_fnSetIconLocation(IShellLinkW * iface, LPCWSTR pszIconPath,INT iIcon)
 {
     _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
 
@@ -1740,7 +1737,6 @@
                                 (lstrlenW( pszPathRel )+1) * sizeof (WCHAR) );
     if ( !This->sPathRel )
         return E_OUTOFMEMORY;
-
     lstrcpyW( This->sPathRel, pszPathRel );
     This->bDirty = TRUE;
 
CVSspam 0.2.8