Fix an issue that Bambu printer camera is not prompted to register due to the Bambu's registry path changes

Fix #5554
This commit is contained in:
SoftFever 2024-06-05 23:21:40 +08:00
parent 6af6a42ed9
commit cb4b84c4ba

View file

@ -78,19 +78,20 @@ void wxMediaCtrl2::Load(wxURI url)
return;
}
{
wxRegKey key1(wxRegKey::HKCR, L"CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32");
wxString path = key1.Exists() ? key1.QueryDefaultValue() : wxString{};
wxRegKey key11(wxRegKey::HKCU, L"SOFTWARE\\Classes\\CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32");
wxRegKey key12(wxRegKey::HKCR, L"CLSID\\" CLSID_BAMBU_SOURCE L"\\InProcServer32");
wxString path = key11.Exists() ? key11.QueryDefaultValue()
: key12.Exists() ? key12.QueryDefaultValue() : wxString{};
wxRegKey key2(wxRegKey::HKCR, "bambu");
wxString clsid;
if (key2.Exists())
key2.QueryRawValue("Source Filter", clsid);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": clsid %1% path %2%") % clsid % path;
if (path.empty() || !wxFile::Exists(path) || clsid != CLSID_BAMBU_SOURCE) {
std::string data_dir_str = Slic3r::data_dir();
boost::filesystem::path data_dir_path(data_dir_str);
auto dll_path = data_dir_path / "plugins" / "BambuSource.dll";
if (path.empty() || !wxFile::Exists(path) || clsid != CLSID_BAMBU_SOURCE) {
if (boost::filesystem::exists(dll_path)) {
CallAfter(
[dll_path] {
@ -132,6 +133,20 @@ void wxMediaCtrl2::Load(wxURI url)
wxPostEvent(this, event);
return;
}
if (path != dll_path) {
static bool notified = false;
if (!notified) CallAfter([dll_path] {
int res = wxMessageBox(_L("Using a BambuSource from a different install, video play may not work correctly! Press Yes to fix it."), _L("Warning"), wxYES_NO | wxICON_WARNING);
if (res == wxYES) {
auto path = dll_path.wstring();
if (path.find(L' ') != std::wstring::npos)
path = L"\"" + path + L"\"";
SHELLEXECUTEINFO info{sizeof(info), 0, NULL, L"open", L"regsvr32", path.c_str(), SW_HIDE};
::ShellExecuteEx(&info);
}
});
notified = true;
}
wxRegKey keyWmp(wxRegKey::HKCU, "SOFTWARE\\Microsoft\\MediaPlayer\\Player\\Extensions\\.");
keyWmp.Create();
long permissions = 0;