From d01749004c8311d7fff7d467ef9cf92c350032c1 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 16 Dec 2012 22:42:30 +0000 Subject: [PATCH] [ui] disable initial update policy prompt if executable is called "rufus.exe" --- src/msapi_utf8.h | 16 +++++++++++++++- src/rufus.h | 4 ++-- src/rufus.rc | 10 +++++----- src/stdlg.c | 23 ++++++++++++++++++----- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/msapi_utf8.h b/src/msapi_utf8.h index a0322551..05a7de50 100644 --- a/src/msapi_utf8.h +++ b/src/msapi_utf8.h @@ -337,7 +337,7 @@ static __inline BOOL GetTextExtentPointU(HDC hdc, const char* lpString, LPSIZE l static __inline DWORD GetCurrentDirectoryU(DWORD nBufferLength, char* lpBuffer) { - DWORD ret = 0, err = ERROR_INVALID_DATA; + DWORD ret = 0, err = ERROR_INVALID_DATA; walloc(lpBuffer, nBufferLength); ret = GetCurrentDirectoryW(nBufferLength, wlpBuffer); err = GetLastError(); @@ -349,6 +349,20 @@ static __inline DWORD GetCurrentDirectoryU(DWORD nBufferLength, char* lpBuffer) return ret; } +static __inline DWORD GetModuleFileNameU(HMODULE hModule, char* lpFilename, DWORD nSize) +{ + DWORD ret = 0, err = ERROR_INVALID_DATA; + walloc(lpFilename, nSize); + ret = GetModuleFileNameW(hModule, wlpFilename, nSize); + err = GetLastError(); + if ((ret != 0) && ((ret = wchar_to_utf8_no_alloc(wlpFilename, lpFilename, nSize)) == 0)) { + err = GetLastError(); + } + wfree(lpFilename); + SetLastError(err); + return ret; +} + static __inline DWORD GetFullPathNameU(const char* lpFileName, DWORD nBufferLength, char* lpBuffer, char** lpFilePart) { DWORD ret = 0, err = ERROR_INVALID_DATA; diff --git a/src/rufus.h b/src/rufus.h index d5ae3b6c..68a0e5f2 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -29,8 +29,8 @@ #define APPLICATION_NAME "Rufus" #define COMPANY_NAME "Akeo Consulting" #define STR_NO_LABEL "NO_LABEL" -#define RUFUS_CANCELBOX_TITLE "Rufus - Cancellation" -#define RUFUS_BLOCKING_IO_TITLE "Rufus - Flushing buffers" +#define RUFUS_CANCELBOX_TITLE APPLICATION_NAME " - Cancellation" +#define RUFUS_BLOCKING_IO_TITLE APPLICATION_NAME " - Flushing buffers" #define DRIVE_INDEX_MIN 0x80 #define DRIVE_INDEX_MAX 0xC0 #define MAX_DRIVES 16 diff --git a/src/rufus.rc b/src/rufus.rc index 5177b6a4..fd04fb53 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 316 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.3.0.212" +CAPTION "Rufus v1.3.0.213" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,278,50,14 @@ -274,8 +274,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,3,0,212 - PRODUCTVERSION 1,3,0,212 + FILEVERSION 1,3,0,213 + PRODUCTVERSION 1,3,0,213 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -292,13 +292,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.3.0.212" + VALUE "FileVersion", "1.3.0.213" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.3.0.212" + VALUE "ProductVersion", "1.3.0.213" END END BLOCK "VarFileInfo" diff --git a/src/stdlg.c b/src/stdlg.c index 3971cf8e..fef84fda 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -1190,7 +1190,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l case IDC_UPDATE_FREQUENCY: if (HIWORD(wParam) != CBN_SELCHANGE) break; - freq = ComboBox_GetItemData(hFrequency, ComboBox_GetCurSel(hFrequency)); + freq = (int32_t)ComboBox_GetItemData(hFrequency, ComboBox_GetCurSel(hFrequency)); WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, (DWORD)freq); EnableWindow(hBeta, (freq >= 0)); return (INT_PTR)TRUE; @@ -1213,6 +1213,8 @@ BOOL SetUpdateCheck(void) BOOL enable_updates; DWORD commcheck = GetTickCount(); notification_info more_info = { IDD_UPDATE_POLICY, UpdateCallback }; + char filename[MAX_PATH] = "", exename[] = APPLICATION_NAME ".exe"; + size_t fn_len, exe_len; // Test if we have access to the registry. If not, forget it. WriteRegistryKey32(REGKEY_COMM_CHECK, commcheck); @@ -1222,10 +1224,21 @@ BOOL SetUpdateCheck(void) // If the update interval is not set, this is the first time we run so prompt the user if (ReadRegistryKey32(REGKEY_UPDATE_INTERVAL) == 0) { - enable_updates = Notification(MSG_QUESTION, &more_info, - APPLICATION_NAME " update policy", "Do you want to allow " APPLICATION_NAME " to check for application updates?\n"); + + // Add a hack for people who'd prefer the app not to prompt about update settings on first run. + // If the executable is called "rufus.exe", without version, we disable the prompt + GetModuleFileNameU(NULL, filename, sizeof(filename)); + fn_len = safe_strlen(filename); + exe_len = safe_strlen(exename); + if ((fn_len > exe_len) && (safe_stricmp(&filename[fn_len-exe_len], exename) == 0)) { + uprintf("Short name used - Disabling initial update policy prompt\n"); + enable_updates = TRUE; + } else { + enable_updates = Notification(MSG_QUESTION, &more_info, APPLICATION_NAME " update policy", + "Do you want to allow " APPLICATION_NAME " to check for application updates?\n"); + } if (!enable_updates) { - WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, -1); // large enough + WriteRegistryKey32(REGKEY_UPDATE_INTERVAL, -1); return FALSE; } // If the user hasn't set the interval in the dialog, set to default @@ -1300,7 +1313,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR safe_free(filepath); EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; - case IDC_DOWNLOAD: // Also doubles as abort and laucnh function + case IDC_DOWNLOAD: // Also doubles as abort and launch function switch(download_status) { case 1: // Abort FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;