Joseph Scandura
2003-10-20 19:04:41 UTC
We assume MS SoundRecorder is running and the file
c:\temp\test.wav exists.
We're trying to send a WM_DROPFILES message to MS
SoundRecorder.
We don't know exactly the format of the structure to send
as an HDROP parameter to the SendMessage (hWndSoundRec,
WM_DROPFILES, (WPARAM) &oMedium, 0L) function.
The message is actually recieved by the Sound Recorder.
However it pops up a message saying:
"File cannot be opened" with random characters (indicating
reading from a non-allocated, or corrupted memory
location) at the end.
We're using the structures STGMEDIUM and DROPFILES as
below.
What are we missing?
int main(int argc, char* argv[])
{
HWND hWndSoundRec = FindWindow ("SoundRec", NULL);
if (hWndSoundRec)
{
HGLOBAL hGlobal = GlobalAlloc (GMEM_FIXED,
sizeof ("k:\\temp\\test.wav") + 2);
char *strFile = (char*) GlobalLock
(hGlobal);
strcpy (strFile, "c:\\temp\\test.wav");
strFile [strlen ("c:\\temp\\test.wav") +
1] = NULL;
POINT point;
point.x = 100;
point.y = 100;
DROPFILES oDropFiles;
oDropFiles.pFiles = (long) &strFile;
oDropFiles.fNC = FALSE;
oDropFiles.fWide = FALSE;
oDropFiles.pt = point;
STGMEDIUM oMedium;
oMedium.tymed = 1;
oMedium.hGlobal = &oDropFiles;
//Send Message with a file reference.
BOOL bSent = SendMessage (hWndSoundRec,
WM_DROPFILES, (WPARAM) &oMedium, 0L);
BOOL bRet = GlobalUnlock (hGlobal);
GlobalFree (hGlobal);
}
return 0;
}
c:\temp\test.wav exists.
We're trying to send a WM_DROPFILES message to MS
SoundRecorder.
We don't know exactly the format of the structure to send
as an HDROP parameter to the SendMessage (hWndSoundRec,
WM_DROPFILES, (WPARAM) &oMedium, 0L) function.
The message is actually recieved by the Sound Recorder.
However it pops up a message saying:
"File cannot be opened" with random characters (indicating
reading from a non-allocated, or corrupted memory
location) at the end.
We're using the structures STGMEDIUM and DROPFILES as
below.
What are we missing?
int main(int argc, char* argv[])
{
HWND hWndSoundRec = FindWindow ("SoundRec", NULL);
if (hWndSoundRec)
{
HGLOBAL hGlobal = GlobalAlloc (GMEM_FIXED,
sizeof ("k:\\temp\\test.wav") + 2);
char *strFile = (char*) GlobalLock
(hGlobal);
strcpy (strFile, "c:\\temp\\test.wav");
strFile [strlen ("c:\\temp\\test.wav") +
1] = NULL;
POINT point;
point.x = 100;
point.y = 100;
DROPFILES oDropFiles;
oDropFiles.pFiles = (long) &strFile;
oDropFiles.fNC = FALSE;
oDropFiles.fWide = FALSE;
oDropFiles.pt = point;
STGMEDIUM oMedium;
oMedium.tymed = 1;
oMedium.hGlobal = &oDropFiles;
//Send Message with a file reference.
BOOL bSent = SendMessage (hWndSoundRec,
WM_DROPFILES, (WPARAM) &oMedium, 0L);
BOOL bRet = GlobalUnlock (hGlobal);
GlobalFree (hGlobal);
}
return 0;
}