[NEW_FEATURE] Updater is ready to go.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@73 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2007-11-14 02:09:36 +00:00
parent 07c17d7c44
commit ae7b901f9e
5 changed files with 32 additions and 16 deletions

View File

@ -56,8 +56,17 @@ BOOL Process::run()
startup.hStdOutput = hPipeOutW; startup.hStdOutput = hPipeOutW;
startup.hStdError = hPipeErrW; startup.hStdError = hPipeErrW;
BOOL started = ::CreateProcess((_type == WIN32_PROG)?_command:NULL, // command is part of input string string cmd = "\"";
(_type == WIN32_PROG)?NULL:_command, // (writeable) command string cmd += _command;
cmd += "\"";
if (_args[0])
{
cmd += " ";
cmd += _args;
}
BOOL started = ::CreateProcess(NULL, // command is part of input string
(LPSTR)cmd.c_str(), // (writeable) command string
NULL, // process security NULL, // process security
NULL, // thread security NULL, // thread security
TRUE, // inherit handles flag TRUE, // inherit handles flag

View File

@ -28,11 +28,12 @@ class Process
{ {
public: public:
Process(progType pt = WIN32_PROG) : _type(pt) {}; Process(progType pt = WIN32_PROG) : _type(pt) {};
Process(const char *cmd, const char *cDir, progType pt = WIN32_PROG) Process(const char *cmd, const char *args, const char *cDir, progType pt = WIN32_PROG)
: _type(pt), _stdoutStr(""), _stderrStr(""), _hPipeOutR(NULL), : _type(pt), _stdoutStr(""), _stderrStr(""), _hPipeOutR(NULL),
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) { _hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) {
strcpy(_command, cmd); strcpy(_command, cmd);
strcpy(_args, args);
strcpy(_curDir, cDir); strcpy(_curDir, cDir);
//_pid = id; //_pid = id;
@ -65,8 +66,9 @@ protected:
progType _type; progType _type;
// LES ENTREES // LES ENTREES
char _command[256]; char _command[MAX_PATH];
char _curDir[256]; char _args[MAX_PATH];
char _curDir[MAX_PATH];
// LES SORTIES // LES SORTIES
string _stdoutStr; string _stdoutStr;

View File

@ -21,10 +21,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "resource.h" #include "resource.h"
#include "menuCmdID.h" #include "menuCmdID.h"
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.6"
#define VERSION_VALUE "4.6\0"
#define VERSION_DIGITALVALUE 4, 6, 0, 0
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_DIGITALVALUE FILEVERSION VERSION_DIGITALVALUE
PRODUCTVERSION VERSION_DIGITALVALUE PRODUCTVERSION VERSION_DIGITALVALUE

View File

@ -18,6 +18,10 @@
#ifndef RESOURCE_H #ifndef RESOURCE_H
#define RESOURCE_H #define RESOURCE_H
#define NOTEPAD_PLUS_VERSION "Notepad++ v4.6"
#define VERSION_VALUE "4.6\0"
#define VERSION_DIGITALVALUE 4, 6, 0, 0
#ifndef IDC_STATIC #ifndef IDC_STATIC
#define IDC_STATIC -1 #define IDC_STATIC -1
#endif #endif

View File

@ -237,7 +237,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh
COPYDATASTRUCT fileNamesData; COPYDATASTRUCT fileNamesData;
fileNamesData.dwData = COPYDATA_FILENAMES; fileNamesData.dwData = COPYDATA_FILENAMES;
//pNppParameters->setCmdlineParam(cmdLineParams);
string quotFileName = "\""; string quotFileName = "\"";
// tell the other running instance the FULL path to the new file to load // tell the other running instance the FULL path to the new file to load
if (lpszCmdLine[0] == '"') if (lpszCmdLine[0] == '"')
@ -268,15 +268,20 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh
Notepad_plus notepad_plus_plus; Notepad_plus notepad_plus_plus;
NppGUI & nppGui = (NppGUI &)pNppParameters->getNppGUI(); NppGUI & nppGui = (NppGUI &)pNppParameters->getNppGUI();
char updaterPath[MAX_PATH];
strcpy(updaterPath, pNppParameters->getNppPath()); string updaterDir = pNppParameters->getNppPath();
strcat(updaterPath, "\\updater\\gup.exe"); updaterDir += "\\updater\\";
bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterPath) == TRUE);
string updaterFullPath = updaterDir + "gup.exe";
string version = VERSION_VALUE;
bool isUpExist = nppGui._doesExistUpdater = (::PathFileExists(updaterFullPath.c_str()) == TRUE);
bool doUpdate = !nppGui._neverUpdate; bool doUpdate = !nppGui._neverUpdate;
if (TheFirstOne && isUpExist && doUpdate) if (TheFirstOne && isUpExist && doUpdate)
{ {
Process updater(updaterPath, "c:\\"); Process updater(updaterFullPath.c_str(), version.c_str(), updaterDir.c_str());
updater.run(); updater.run();
} }
@ -312,7 +317,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh
if (i == 106901) if (i == 106901)
::MessageBox(NULL, "Scintilla.init is failed!", "106901", MB_OK); ::MessageBox(NULL, "Scintilla.init is failed!", "106901", MB_OK);
else { else {
char str[50] = "God Damn Exception : "; char str[50] = "God Damned Exception : ";
char code[10]; char code[10];
itoa(i, code, 10); itoa(i, code, 10);
::MessageBox(NULL, strcat(str, code), "int exception", MB_OK); ::MessageBox(NULL, strcat(str, code), "int exception", MB_OK);