From eb672a9abf26dfeebd2e4ebfb888093e8d538e0a Mon Sep 17 00:00:00 2001 From: eliboa Date: Fri, 18 May 2018 22:30:14 +0200 Subject: [PATCH] Fixed driver install prompt at every startup --- TegraRcmGUIDlg.cpp | 33 ++++++++++++++++++--------------- TegraRcmGUIDlg.h | 1 + 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/TegraRcmGUIDlg.cpp b/TegraRcmGUIDlg.cpp index ea66a89..16f1552 100644 --- a/TegraRcmGUIDlg.cpp +++ b/TegraRcmGUIDlg.cpp @@ -73,10 +73,10 @@ BOOL CTegraRcmGUIDlg::OnInitDialog() RCM_BITMAP1.SetBitmap(RCM_NOT_DETECTED); RCM_BITMAP2.SetBitmap(DRIVER_KO); RCM_BITMAP3.SetBitmap(RCM_DETECTED); - + BOOL isDriverInstalled = LookForDriver(); if (!isDriverInstalled) InstallDriver(); - + string value = GetPreset("AUTO_INJECT"); if (value == "TRUE") { @@ -226,14 +226,9 @@ void CTegraRcmGUIDlg::OnTimer(UINT nIDEvent) this->GetDlgItem(IDC_SHOFEL2)->EnableWindow(FALSE); s = "lbusbK driver is needed !"; - /* - if (!ASK_FOR_DRIVER) - { - ASK_FOR_DRIVER = TRUE; - InstallDriver(); - - } - */ + + if (!ASK_FOR_DRIVER) InstallDriver(); + } else { @@ -539,13 +534,21 @@ void CTegraRcmGUIDlg::InstallDriver() CloseHandle(shExInfo.hProcess); } } + ASK_FOR_DRIVER = TRUE; } typedef int(__cdecl *MYPROC)(LPWSTR); + BOOL CTegraRcmGUIDlg::LookForDriver() { - CString LIBUSBKDLL = _T("C:\\Windows\\System32\\libusbK.dll"); - std::ifstream infile(LIBUSBKDLL); - BOOL file_exists = infile.good(); - return file_exists; -} \ No newline at end of file + TCHAR system_dir[MAX_PATH]; + HRESULT result = SHGetFolderPath(NULL, CSIDL_SYSTEM, NULL, SHGFP_TYPE_CURRENT, system_dir); + if (result != S_OK) return FALSE; + PathAppend(system_dir, _T("\\libusbK.dll")); + + + std::ifstream infile32(system_dir); + BOOL file_exists32 = infile32.good(); + if (!file_exists32) return FALSE; + +} diff --git a/TegraRcmGUIDlg.h b/TegraRcmGUIDlg.h index 605dca7..87dc10a 100644 --- a/TegraRcmGUIDlg.h +++ b/TegraRcmGUIDlg.h @@ -19,6 +19,7 @@ #include + // CTegraRcmGUIDlg dialog class CTegraRcmGUIDlg : public CDialog {