[sword-svn] r495 - branches/BCB5
chrislit at crosswire.org
chrislit at crosswire.org
Sat Mar 7 23:13:22 MST 2009
Author: chrislit
Date: 2009-03-07 23:13:22 -0700 (Sat, 07 Mar 2009)
New Revision: 495
Modified:
branches/BCB5/sword.cpp
Log:
added commandline option "--noreg" to prevent writing private protocol stuff to registry (look, magically we have a PortableApps edition--that was difficult)
also did a little cleanup (removed unused ThMLPlain filter stuff)
Modified: branches/BCB5/sword.cpp
===================================================================
--- branches/BCB5/sword.cpp 2009-03-04 08:28:01 UTC (rev 494)
+++ branches/BCB5/sword.cpp 2009-03-08 06:13:22 UTC (rev 495)
@@ -5,10 +5,7 @@
#include <winreg.h>
#include <dir.h>
#include "sword.h"
-#include <thmlplain.h>
-using namespace sword;
-
USERES("sword.res");
USEFORM("mainfrm.cpp", Form1);
USEFORM("AboutBoxfrm.cpp", AboutBox);
@@ -60,11 +57,11 @@
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
LONG result;
+ bool noRegistry = false;
try {
HKEY hkey;
HWND otherInst;
- ThMLPlain filter;
// see if there's a previous instance running
AnsiString titleString = Application->Title;
@@ -76,7 +73,9 @@
int len = (strlen(lpCmdLine) + 1) * 5;
char *buf = new char [len + 1];
strcpy(buf, lpCmdLine);
-// filter.ProcessText(buf, len);
+
+ noRegistry = !strncmp(lpCmdLine, "--noreg", 7);
+
while (true) {
char *change = strstr(buf, "%20");
if (change) {
@@ -95,7 +94,7 @@
}
}
- if (otherInst != NULL) {
+ if (otherInst != NULL && !noRegistry) {
result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\OpenVerse", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
result = RegSetValueEx(hkey, NULL, 0, REG_SZ, buf, strlen(buf) + 1);
result = RegCloseKey(hkey);
@@ -118,18 +117,19 @@
delete [] buf;
}
- // adjust the registry for our private protocol using the current path
- result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
- result = RegSetValueEx(hkey, NULL, 0, REG_SZ, "URL:SWORD Protocol", strlen("URL:SWORD Protocol") + 1);
- result = RegSetValueEx(hkey, "URL Protocol", 0, REG_SZ, "", 1);
- result = RegCloseKey(hkey);
- result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\DefaultIcon", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
- result = RegSetValueEx(hkey, NULL, 0, REG_SZ, Application->ExeName.c_str(), Application->ExeName.Length() + 1);
- result = RegCloseKey(hkey);
- AnsiString opencommand = Application->ExeName + " \"%1\"";
- result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\shell\\open\\command", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
- result = RegSetValueEx(hkey, NULL, 0, REG_SZ, opencommand.c_str(), opencommand.Length() + 1);
- result = RegCloseKey(hkey);
+ // adjust the registry for our private protocol using the current path (unless we're running in noRegistry mode for PortableApps)
+ if (!noRegistry) {
+ result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
+ result = RegSetValueEx(hkey, NULL, 0, REG_SZ, "URL:SWORD Protocol", strlen("URL:SWORD Protocol") + 1);
+ result = RegSetValueEx(hkey, "URL Protocol", 0, REG_SZ, "", 1);
+ result = RegCloseKey(hkey);
+ result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\DefaultIcon", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
+ result = RegSetValueEx(hkey, NULL, 0, REG_SZ, Application->ExeName.c_str(), Application->ExeName.Length() + 1);
+ result = RegCloseKey(hkey);
+ AnsiString opencommand = Application->ExeName + " \"%1\"";
+ result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\shell\\open\\command", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL);
+ result = RegSetValueEx(hkey, NULL, 0, REG_SZ, opencommand.c_str(), opencommand.Length() + 1);
+ result = RegCloseKey(hkey);
/*
@@ -159,7 +159,8 @@
result = RegCloseKey(hkey);
}
*/
- }
+ }
+ }
catch (Exception &exception) {
Application->ShowException(&exception);
}
More information about the sword-cvs
mailing list