diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp index 49d40b36f..c32a66545 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp @@ -344,6 +344,7 @@ void RegExtDlg::writeNppPath() // Write the value for new document ::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey); ::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR)); + RegCloseKey(hRootKey); TCHAR nppPath[MAX_PATH]; ::GetModuleFileName(_hInst, nppPath, MAX_PATH); @@ -355,4 +356,33 @@ void RegExtDlg::writeNppPath() } RegCloseKey(hKey); } + + //Set default icon value + lstrcpy(regStr, nppName); + lstrcat(regStr, TEXT("\\DefaultIcon")); + nRet = ::RegCreateKeyEx( + HKEY_CLASSES_ROOT, + regStr, + 0, + NULL, + 0, + KEY_ALL_ACCESS, + NULL, + &hKey, + &dwDisp); + + if (nRet == ERROR_SUCCESS) + { + //if (dwDisp == REG_CREATED_NEW_KEY) + { + TCHAR nppPath[MAX_PATH]; + ::GetModuleFileName(_hInst, nppPath, MAX_PATH); + + TCHAR nppPathParam[256] = TEXT("\""); + lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0")); + + ::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); + } + RegCloseKey(hKey); + } } diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 07cb843ed..b74cfacb7 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -34,7 +34,25 @@ bool checkSingleFile(const TCHAR * commandLine) { return false; } +//commandLine should contain path to n++ executable running void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) { + //params.erase(params.begin()); + //remove the first element, since thats the path the the executable (GetCommandLine does that) + TCHAR stopChar = TEXT(' '); + int i = 0; + if (commandLine[0] == TEXT('\"')) { + stopChar = TEXT('\"'); + commandLine++; + } + //while this is not really DBCS compliant, space and quote are in the lower 127 ASCII range + while(commandLine[0] && commandLine[0] != stopChar) + commandLine++; + commandLine++; //advance past stopChar + //kill remaining spaces + while(commandLine[0] == TEXT(' ')) + commandLine++; + + bool isFile = checkSingleFile(commandLine); //if the commandline specifies only a file, open it as such if (isFile) { paramVector.push_back(commandLine); @@ -129,8 +147,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR cmdLineAnsi, int nCmdSh LPTSTR cmdLine = ::GetCommandLine(); ParamVector params; parseCommandLine(cmdLine, params); - params.erase(params.begin()); //remove the first element, since thats the path the the executable (GetCommandLine does that) - bool TheFirstOne = true; ::SetLastError(NO_ERROR);