LPWSTR sComponent;
volume_info volume;
LPWSTR sLinkPath;
+ LPWSTR sCurFile;
BOOL bRunAs;
BOOL bDirty;
INT iIdOpen; /* id of the "Open" entry in the context menu */
/* strdup on the process heap */
static LPWSTR __inline HEAP_strdupAtoW( HANDLE heap, DWORD flags, LPCSTR str)
{
+ assert(str);
INT len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
LPWSTR p = HeapAlloc( heap, flags, len*sizeof (WCHAR) );
if( !p )
IStream_Release( stm );
if( SUCCEEDED( r ) )
- {
+ {
+ if ( This->sLinkPath )
+ {
+ HeapFree(GetProcessHeap(), 0, This->sLinkPath);
+ }
+ This->sLinkPath = HeapAlloc(GetProcessHeap(), 0, (wcslen(pszFileName)+1) * sizeof(WCHAR));
+ if ( This->sLinkPath )
+ {
+ wcscpy(This->sLinkPath, pszFileName);
+ }
+
StartLinkProcessor( pszFileName );
This->bDirty = FALSE;
}
- else
+ else
{
DeleteFileW( pszFileName );
WARN("Failed to create shortcut %s\n", debugstr_w(pszFileName) );
static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile* iface, LPOLESTR *ppszFileName)
{
- IShellLinkImpl *This = impl_from_IPersistFile(iface);
- FIXME("(%p)\n",This);
- return NOERROR;
+ IShellLinkImpl *This = impl_from_IPersistFile(iface);
+
+ *ppszFileName = NULL;
+
+ if ( !This->sLinkPath)
+ {
+ /* IPersistFile::GetCurFile called before IPersistFile::Save */
+ return S_FALSE;
+ }
+
+ *ppszFileName = CoTaskMemAlloc((wcslen(This->sLinkPath)+1) * sizeof(WCHAR));
+ if (!*ppszFileName)
+ {
+ /* out of memory */
+ return E_OUTOFMEMORY;
+ }
+
+ /* copy last saved filename */
+ wcscpy(*ppszFileName, This->sLinkPath);
+
+ return NOERROR;
}
static const IPersistFileVtbl pfvt =
TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%u)(%s)\n",
This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath));
- if (This->sComponent || This->sProduct)
- return S_FALSE;
-
if (cchMaxPath)
pszFile[0] = 0;
if (This->sPath)
TRACE("(%p)->(pName=%s)\n", This, pszName);
HeapFree(GetProcessHeap(), 0, This->sDescription);
- This->sDescription = HEAP_strdupAtoW( GetProcessHeap(), 0, pszName);
- if ( !This->sDescription )
- return E_OUTOFMEMORY;
+ This->sDescription = NULL;
+ if ( pszName ) {
+ This->sDescription = HEAP_strdupAtoW( GetProcessHeap(), 0, pszName);
+ if ( !This->sDescription )
+ return E_OUTOFMEMORY;
+ }
This->bDirty = TRUE;
return S_OK;
TRACE("(%p)->(dir=%s)\n",This, pszDir);
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
- This->sWorkDir = HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir);
- if ( !This->sWorkDir )
- return E_OUTOFMEMORY;
+ This->sWorkDir = NULL;
+ if ( pszDir ) {
+ This->sWorkDir = HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir);
+ if ( !This->sWorkDir )
+ return E_OUTOFMEMORY;
+ }
This->bDirty = TRUE;
return S_OK;
TRACE("(%p)->(args=%s)\n",This, pszArgs);
HeapFree(GetProcessHeap(), 0, This->sArgs);
- This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
- if( !This->sArgs )
- return E_OUTOFMEMORY;
+ This->sArgs = NULL;
+
+ if ( pszArgs ) {
+ This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
+ if( !This->sArgs )
+ return E_OUTOFMEMORY;
+ }
This->bDirty = TRUE;
TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
- This->sIcoPath = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
- if ( !This->sIcoPath )
- return E_OUTOFMEMORY;
+ This->sIcoPath = NULL;
+
+ if ( pszIconPath ) {
+ This->sIcoPath = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
+ if ( !This->sIcoPath )
+ return E_OUTOFMEMORY;
+ }
This->iIcoNdx = iIcon;
This->bDirty = TRUE;
TRACE("(%p)->(path=%s %x)\n",This, pszPathRel, dwReserved);
HeapFree(GetProcessHeap(), 0, This->sPathRel);
- This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
+ This->sPathRel = NULL;
+
+ if ( pszPathRel ) {
+ This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
+
+ if ( !This->sPathRel )
+ return E_OUTOFMEMORY;
+ }
+
This->bDirty = TRUE;
return ShellLink_UpdatePath(This->sPathRel, This->sPath, This->sWorkDir, &This->sPath);