Hello all, I had completed the patch for IPersistFile::Load() and associated functions. In the last patch which I had submitted for review here, Mike McCormack had pointed out an incorrect assumption that I had made about all locales being DBCS. Thanks to him, many of you will not suffer ;)
Now that I fixed that last (?) weeny, I had sent it to Mike for a review. However, it seems he's a bit down now, and after waiting for about a week for his reply, I thought maybe I should ask you guys to nitpick ;) I really send this in because I went through Mike Kost's post 'More Games Tested', and I saw lots of 'err:menubuilder' and 'err:menubuilder:WinMain failed to build menu item for C:\windows\Start Menu\Programs\.......\ShortcutName.lnk' messages in his report. Hopefully, this patch should solve it ... If I get any bug reports, I will be happy to fill them out,else this one's going to Alexandre (with a few cosmetic changes of course !) Regards Subhobroto Sinha
--- shelllink.c.original 2003-10-22 17:56:30.000000000 +0530
+++ shelllink.c 2003-12-24 22:29:59.000000000 +0530
@@ -401,9 +400,49 @@
return S_OK;
}
+static HRESULT Stream_LoadString( IStream* stm, BOOL unicode,LPWSTR *pstr )
+{
+ DWORD count=0;
+ USHORT len;
+ LPWSTR str=NULL;
+ HRESULT r;
+ /*
+ From Win98 upwards everything internally is maintained as unicode.(Atleast M$
says so)
+ Also, the value of SCF_UNICODE does NOT seem to be 0x1000, hence the bitwise '&'
returns a false, even if it's unicode.
+ Until the correct value is found, we assume it Unicode. This should not break
ANYTHING >Win95 for shortcuts
+ Anybody differing mail to <subhobrotosinha at yahoo.com>.
+ */
+ TRACE("%p\n", stm);
+
+ r = IStream_Read(stm, &len, sizeof(len), &count);
+ if(FAILED(r)||(count != sizeof(len))) return E_FAIL;
+ len *= sizeof(WCHAR);
+
+ TRACE("reading %d\n", len);
+ str = HeapAlloc(GetProcessHeap(), 0, len+sizeof(WCHAR));
+ if(!str) return E_OUTOFMEMORY;
+
+ count = 0;
+ r = IStream_Read(stm, str, len, &count);
+ if( FAILED(r)||( count!=len) )
+ {
+ HeapFree( GetProcessHeap(), 0, str );
+ return E_FAIL;
+ }
+
+ str[count/2]=0;
+ *pstr = str;
+ TRACE("read %s\n", debugstr_w(str));
+ return S_OK;
+}
+
+#if 0
static HRESULT Stream_LoadString( IStream* stm, BOOL unicode, LPWSTR *pstr )
{
+ /*This is the original function now redirected to the above till we find out
correct 'SCF_UNICODE'.
+ Now it's assumed that the data's unicode. (This assumption failes iff the OS was
<=Win95, so I don't think it will hurt anybody)*/
+
DWORD count;
USHORT len;
LPVOID temp;
@@ -454,6 +493,7 @@
return S_OK;
}
+#endif
static HRESULT Stream_LoadLocation( IStream* stm )
{
@@ -503,9 +543,10 @@
IStream* stm)
{
LINK_HEADER hdr;
- ULONG dwBytesRead;
+ ULONG dwBytesRead=0;
BOOL unicode;
WCHAR sTemp[MAX_PATH];
+ WCHAR wszTemp[MAX_PATH]={0};
HRESULT r;
_ICOM_THIS_From_IPersistStream(IShellLinkImpl, iface);
@@ -515,7 +556,6 @@
if( !stm )
return STG_E_INVALIDPOINTER;
- dwBytesRead = 0;
r = IStream_Read(stm, &hdr, sizeof(hdr), &dwBytesRead);
if( FAILED( r ) )
return r;
@@ -533,6 +573,12 @@
if( FAILED( r ) )
return r;
}
+
+ SHGetPathFromIDListW(This->pPidl,wszTemp);
+ This->sPath = HeapAlloc( GetProcessHeap(), 0, lstrlenW(wszTemp)*sizeof(WCHAR) );
+ lstrcpyW(This->sPath,wszTemp);
+ TRACE("%s\n",debugstr_w(This->sPath));
+
This->wHotKey = hdr.wHotKey;
This->iIcoNdx = hdr.nIcon;
FileTimeToSystemTime (&hdr.Time1, &This->time1);
diff.zip
Description: Zip compressed data
