通过读取Shell 中接口(IID_IShellDispatch), 使用此方式MinizeAll() 来最小化窗体, 并通过UndoMinizeAll()来恢复。
这个功能比起Window提供的[显示桌面]来, 功能还是有局限性的,此方法仅用于所有顶层窗体不存在模态对话框时才起作用。
一、关键代码块
IShellDispatch *pDispatch;
CoInitialize(NULL);
if (CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC, IID_IShellDispatch, (void **)&pDispatch) == S_OK)
{
pDispatch->MinimizeAll();
pDispatch->Release();
}
CoUninitialize();
CoInitialize(NULL);
if (CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC, IID_IShellDispatch, (void **)&pDispatch) == S_OK)
{
pDispatch->MinimizeAll();
pDispatch->Release();
}
CoUninitialize();