im getting this error:
error C2712: Cannot use __try in functions that require object unwinding

how to fix this?


struct EnumFilesConfig
{
    int  maxNestLevel = 0;
    std::map<int, int> maxItemsPerLevel;
    int  currentLevel       = 0;
};

void enumFiles(const wchar_t* t, std::map<std::string, std::string>& jsonObject, EnumFilesConfig config = {})
{
    __try
    {
        VM_FISH_WHITE_START // VM_F443
        CComPtr<IShellItem> pItem = NULL;
        HRESULT hr = SHCreateItemFromParsingName(t, nullptr, IID_PPV_ARGS(&pItem));
        if (hr != S_OK || !pItem)
            return;

        DWORD attributes = 0;
        hr = pItem->GetAttributes(SFGAO_STORAGE | SFGAO_FOLDER | SFGAO_LINK, &attributes);
        bool isFolder = ((attributes & SFGAO_FOLDER) && (attributes & SFGAO_STORAGE));
        if (isFolder)
        {
            CComPtr<IEnumShellItems> items;
            CComPtr<IPropertyBag> bag;
            CComPtr<IBindCtx> ctx;
            PSCreateMemoryPropertyStore(IID_PPV_ARGS(&bag));
            CreateBindCtx(0, &ctx);
            if (bag && ctx)
            {
                ctx->RegisterObjectParam((LPOLESTR)STR_PROPERTYBAG_PARAM, bag);
                ATL::CComVariant flags = CComVariant(SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN | SHCONTF_NONFOLDERS);
                bag->Write(STR_ENUM_ITEMS_FLAGS, &flags);
            }

            hr = pItem->BindToHandler(ctx, BHID_EnumItems, IID_PPV_ARGS(&items));
            if (FAILED(hr) || !items)
                return;

            std::map<std::string, std::string> folderObject;
            int maxItems = config.maxItemsPerLevel[config.currentLevel];
            if (!maxItems)
                maxItems = 100; // Default to 100 if not specified

            int itemCount = 0;
            do
            {
                CComPtr<IShellItem> pChildItem;
                if (itemCount >= maxItems || items->Next(1, &pChildItem, nullptr) != S_OK)
                    break;

                itemCount++;
                if (config.currentLevel < config.maxNestLevel)
                {
                    LPWSTR name;
                    pChildItem->GetDisplayName(SIGDN_FILESYSPATH, &name);
                    if (name == NULL || !name[0])
                        continue;

                    EnumFilesConfig newConfig = config;
                    newConfig.currentLevel++;
                    enumFiles(name, folderObject, newConfig);
                }
                else
                {
                    attributes = 0;
                    hr = pChildItem->GetAttributes(SFGAO_FOLDER, &attributes);
                    bool isFolder = (FAILED(hr) || (attributes & SFGAO_FOLDER));

                    LPWSTR name;
                    pChildItem->GetDisplayName(SIGDN_FILESYSPATH, &name);
                    if (!name || !name[0])
                        continue;

                    //QString string = QString::fromWCharArray(name);
                    //QByteArray file(string.toUtf8());
                    //folderObject.emplace(file.data(), "");
                }

            } while (true);
        }
        VM_FISH_WHITE_END
    }
	__except (EXCEPTION_EXECUTE_HANDLER)
	{
		return;
	}
}

void runEnumFiles()
{
    CoInitialize(NULL);
	std::map<std::string, std::string> map;
    ::enumFiles(L"C:\\Users\\RUAN\\Desktop", map, EnumFilesConfig{
        .maxNestLevel = 2,
        .maxItemsPerLevel = { {0, 100}, {1, 50}, {2, 50} }
    });
    std::cout << "ok";
}

int main(int argc, char *argv[])
{
    std::thread t1(runEnumFiles);
    std::thread t2(runEnumFiles);
    std::thread t3(runEnumFiles);
    std::thread t4(runEnumFiles);

    t1.join();
    t2.join();
    t3.join();
    t4.join();

	system("pause");
    
    return 0;
}