🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
ShellCOMUtils.hpp
浏览该文件的文档.
1
11
12#pragma once
13
14#if defined(_WIN32) && !defined(SWIG)
15
16#include "AstGlobal.h"
17
18#include <Windows.h>
19#include <shlobj.h>
20#include <string>
21
22AST_NAMESPACE_BEGIN
23
29inline bool aShellWaitForItem(Folder* pFolder, const std::wstring& itemName,
30 unsigned long timeoutMs = 30000)
31{
32 unsigned long start = GetTickCount();
33
34 while ((GetTickCount() - start) < timeoutMs)
35 {
36 FolderItem* pCheck = nullptr;
37 BSTR bstrName = SysAllocString(itemName.c_str());
38 if (!bstrName) return false;
39 HRESULT hr = pFolder->ParseName(bstrName, &pCheck);
40 SysFreeString(bstrName);
41
42 if (SUCCEEDED(hr) && pCheck != nullptr)
43 {
44 pCheck->Release();
45 return true;
46 }
47 Sleep(100);
48 }
49 return false;
50}
51
52AST_NAMESPACE_END
53
54#endif // _WIN32