Re: A weird problem: SetVolumeLabel() should take a very long time to complete.
I suspect SetVolumeLabel causes a shell notification to be sent to all
threads with a message pump. After you call MessageBox, your thread becomes
a message pump (GUI) thread. Thus, a broadcast causes a deadlock.
"xmllmx" <xmllmx@gmail.com> wrote in message
news:1189955954.538045.105730@w3g2000hsg.googlegroups.com...
Hi group,
I came across a simple but strange problem. Let me use real code
fragment to begin with:
=========== Code Fragment 1 Begin =============
void Func1()
{
DeleteVolumeMountPoint(L"E:\\");
SetVolumeMountPoint(L"E:\\", L"\\\\\?\\Volume{c1b44900-63f2-11dc-
b23e-0003ff73ce8b}");
SetVolumeLabel(L"E:\\", L"Hello");
}
=========== Code Fragment 1 End ===============
The function Func1 above works fine and immediately return without any
delay. OK.
However, when I inserted a AfxMessageBox() into the function body,
just as Func2 below.
=========== Code Fragment 2 Begin =============
void Func2()
{
DeleteVolumeMountPoint(L"E:\\");
AfxMessageBox(L"OK");
SetVolumeMountPoint(L"E:\\", L"\\\\\?\\Volume{c1b44900-63f2-11dc-
b23e-0003ff73ce8b}");
SetVolumeLabel(L"E:\\", L"Hello");
}
=========== Code Fragment 2 End ===============
Now, the thing became weird and hard to understand: The function Func2
should take a very long time (about 20 seconds!) to complete its task.
Or to be more exact, the statement SetVolumeLabel(L"E:\\", L"Hello");
would take a very long time to complete its task.
I can't understand why AfxMessageBox(L"OK"); should affect the
behavior of SetVolumeLabel(L"E:\\", L"Hello");
Hope someboby can help me, many thanks in advance.