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\n",stm);
- r = IStream_Read( stm, &buffer.cbSize, sizeof (DWORD), &count );
+ r = IStream_Read( stm, &buffer.dbh.cbSize, sizeof (DWORD), &count );
if( FAILED( r ) )
return r;
/* make sure that we read the size of the structure even on error */
size = sizeof buffer - sizeof (DWORD);
- if( buffer.cbSize != sizeof buffer )
+ if( buffer.dbh.cbSize != sizeof buffer )
{
ERR("Ooops. This structure is not as expected...\n");
return E_FAIL;
}
- r = IStream_Read( stm, &buffer.dwSignature, size, &count );
+ r = IStream_Read( stm, &buffer.dbh.dwSignature, size, &count );
if( FAILED( r ) )
return r;
if( count != size )
return E_FAIL;
- TRACE("magic %08x string = %s\n", buffer.dwSignature, debugstr_w(buffer.szwDarwinID));
+ TRACE("magic %08x string = %s\n", buffer.dbh.dwSignature, debugstr_w(buffer.szwDarwinID));
- if( (buffer.dwSignature&0xffff0000) != 0xa0000000 )
+ if( (buffer.dbh.dwSignature&0xffff0000) != 0xa0000000 )
{
- ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dwSignature);
+ ERR("Unknown magic number %08x in advertised shortcut\n", buffer.dbh.dwSignature);
return E_FAIL;
}
EXP_DARWIN_LINK *buffer;
buffer = LocalAlloc( LMEM_ZEROINIT, sizeof *buffer );
- buffer->cbSize = sizeof *buffer;
- buffer->dwSignature = magic;
+ buffer->dbh.cbSize = sizeof *buffer;
+ buffer->dbh.dwSignature = magic;
lstrcpynW( buffer->szwDarwinID, string, MAX_PATH );
WideCharToMultiByte(CP_ACP, 0, string, -1, buffer->szDarwinID, MAX_PATH, NULL, NULL );
buffer = shelllink_build_darwinid( string, magic );
- return IStream_Write( stm, buffer, buffer->cbSize, &count );
+ return IStream_Write( stm, buffer, buffer->dbh.cbSize, &count );
}
/************************************************************************
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);
case 14021:
if (This->sIcoPath)
wcscpy(szBuffer, This->sIcoPath);
+ else
+ wcscpy(szBuffer, This->sPath);
+
IconIndex = This->iIcoNdx;
if (PickIconDlg(hwndDlg, szBuffer, MAX_PATH, &IconIndex))
{
}
else if (This->sArgs != NULL)
{
- args = This->sArgs;
+ args = strdupW( This->sArgs );
}
memset( &sei, 0, sizeof sei );