summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-09-17 12:24:30 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-09-17 12:24:30 +0000
commit23173a574dfe43f1df9764d25592f22f88fec8e6 (patch)
treed114f21a9e709ab6b3d6a0e86d3ce248c17b0294
parent8dd8bfc750f75dd0d89342fd59130516352100a9 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@1588 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/AutoRun/src/main.cpp75
1 files changed, 32 insertions, 43 deletions
diff --git a/plugins/AutoRun/src/main.cpp b/plugins/AutoRun/src/main.cpp
index c953afe6f1..26af671bcd 100644
--- a/plugins/AutoRun/src/main.cpp
+++ b/plugins/AutoRun/src/main.cpp
@@ -1,7 +1,6 @@
#include "autorun.h"
HINSTANCE hInst;
-HANDLE hHookOptionInit = NULL;
int hLangpack;
PLUGININFOEX pluginInfoEx=
@@ -23,9 +22,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
hInst = hinstDLL;
return TRUE;
}
+
void GetProfilePath(TCHAR *res)
{
- TCHAR dbname[MAX_PATH], dbpath[MAX_PATH], exename[MAX_PATH];
+ TCHAR dbname[MAX_PATH], dbpath[MAX_PATH], exename[MAX_PATH];
CallService(MS_DB_GETPROFILENAMET, SIZEOF(dbname), (LPARAM)(TCHAR*) dbname);
CallService(MS_DB_GETPROFILEPATHT, SIZEOF(dbpath), (LPARAM)(TCHAR*) dbpath);
GetModuleFileName(NULL,exename, SIZEOF(exename));
@@ -38,66 +38,57 @@ void GetProfilePath(TCHAR *res)
static void SetAutorun(BOOL autorun)
{
- HKEY hKey;
- DWORD dw;
- switch (autorun)
- {
- case TRUE:
- if (RegCreateKeyEx(ROOT_KEY, SUB_KEY, 0, NULL, 0, KEY_CREATE_SUB_KEY|KEY_SET_VALUE,NULL,&hKey,&dw) == ERROR_SUCCESS)
- {
- TCHAR result[MAX_PATH];
- GetProfilePath(result);
- RegSetValueEx(hKey, _T("MirandaNG"), 0, REG_SZ, (BYTE*)result, lstrlen(result)+1);
- RegCloseKey(hKey);
+ HKEY hKey;
+ DWORD dw;
+ switch (autorun) {
+ case TRUE:
+ if (RegCreateKeyEx(ROOT_KEY, SUB_KEY, 0, NULL, 0, KEY_CREATE_SUB_KEY|KEY_SET_VALUE,NULL,&hKey,&dw) == ERROR_SUCCESS) {
+ TCHAR result[MAX_PATH];
+ GetProfilePath(result);
+ RegSetValueEx(hKey, _T("MirandaNG"), 0, REG_SZ, (BYTE*)result, lstrlen(result)+1);
+ RegCloseKey(hKey);
+ }
break;
- }
- case FALSE:
- if (RegOpenKey(ROOT_KEY, SUB_KEY, &hKey) == ERROR_SUCCESS)
- {
- RegDeleteValue(hKey, _T("MirandaNG"));
- RegCloseKey(hKey);
+ case FALSE:
+ if (RegOpenKey(ROOT_KEY, SUB_KEY, &hKey) == ERROR_SUCCESS) {
+ RegDeleteValue(hKey, _T("MirandaNG"));
+ RegCloseKey(hKey);
+ }
break;
}
- }
}
static BOOL CmpCurrentAndRegistry()
{
HKEY hKey;
- DWORD dwBufLen = MAX_PATH;
+ if ( RegOpenKeyEx(ROOT_KEY, SUB_KEY, 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
+ return FALSE;
+
TCHAR result[MAX_PATH], dbpath[MAX_PATH];
- GetProfilePath(result);
-
- if (RegOpenKeyEx(ROOT_KEY, SUB_KEY, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
- {
- if (RegQueryValueEx(hKey, _T("MirandaNG"), NULL, NULL, (LPBYTE)dbpath, &dwBufLen) == ERROR_SUCCESS)
- {
- return (lstrcmpi(result,dbpath) == 0 ? TRUE : FALSE);
- }
- else
- return FALSE;
- }
- else
+ DWORD dwBufLen = MAX_PATH;
+ if ( RegQueryValueEx(hKey, _T("MirandaNG"), NULL, NULL, (LPBYTE)dbpath, &dwBufLen) != ERROR_SUCCESS)
return FALSE;
+
+ GetProfilePath(result);
+ return lstrcmpi(result,dbpath) == 0;
}
static INT_PTR CALLBACK DlgProcAutorunOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg,IDC_AUTORUN,CmpCurrentAndRegistry()); // Check chekbox if Registry value exists
+ CheckDlgButton(hwndDlg,IDC_AUTORUN,CmpCurrentAndRegistry()); // Check chekbox if Registry value exists
return TRUE;
+
case WM_COMMAND:
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); // Send message to activate "Apply" button
return TRUE;
- break;
+
case WM_NOTIFY:
switch(((LPNMHDR)lParam)->idFrom) {
case 0:
- switch (((LPNMHDR)lParam)->code)
- {
+ switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY: // if "Apply" pressed then...
SetAutorun(IsDlgButtonChecked(hwndDlg,IDC_AUTORUN)); //Save changes to registry;
return TRUE;
@@ -132,13 +123,11 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
extern "C" __declspec(dllexport) int Load(void)
{
mir_getLP(&pluginInfoEx);
- hHookOptionInit = HookEvent(ME_OPT_INITIALISE, AutorunOptInitialise);
+ HookEvent(ME_OPT_INITIALISE, AutorunOptInitialise);
return 0;
}
extern "C" __declspec(dllexport) int Unload(void)
{
- if (hHookOptionInit)
- UnhookEvent(hHookOptionInit);
return 0;
-} \ No newline at end of file
+}