Hi Huw,
I sent another try. Thanks for the review!
On 3/9/21 8:48 PM, Huw Davies wrote:
On Tue, Mar 09, 2021 at 11:57:01AM +0800, Jactry Zeng wrote:
+static HDROP create_dropped_file(void) +{
- WCHAR path[] = L"C:\testfile1";
You need to escape the backslash. Also, it would most likely be easier to include the second \0 in the string ie. L"C:\testfile1\0" and then use memcpy to copy it.
- DROPFILES *dropfiles;
- DWORD size, offset;
- HDROP hdrop;
- size = sizeof(DROPFILES) + (sizeof(path) + 1) * sizeof(WCHAR);
This is wrong.
- offset = sizeof(DROPFILES);
- hdrop = GlobalAlloc(GHND, size);
- dropfiles = GlobalLock(hdrop);
- dropfiles->pFiles = offset;
- dropfiles->fWide = TRUE;
- lstrcpyW(((WCHAR *)dropfiles) + offset, path);
As is this - offset is a byte offset...
- offset += lstrlenW(path) + 1;
...which seems to turn into a WCHAR offset.
- ((WCHAR *)dropfiles)[offset] = 0;
- GlobalUnlock(hdrop);
- return hdrop;
+}