diff options
Diffstat (limited to 'apps/windoze/CBuilder5/BibleCS/sword.cpp')
-rw-r--r-- | apps/windoze/CBuilder5/BibleCS/sword.cpp | 80 |
1 files changed, 53 insertions, 27 deletions
diff --git a/apps/windoze/CBuilder5/BibleCS/sword.cpp b/apps/windoze/CBuilder5/BibleCS/sword.cpp index 6bc578e..0bdf69a 100644 --- a/apps/windoze/CBuilder5/BibleCS/sword.cpp +++ b/apps/windoze/CBuilder5/BibleCS/sword.cpp @@ -5,6 +5,7 @@ #include <winreg.h> #include <dir.h> #include "sword.h" +#include <thmlplain.h> USERES("sword.res"); USEFORM("mainfrm.cpp", Form1); @@ -55,17 +56,41 @@ WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, in try { HKEY hkey; HWND otherInst; + ThMLPlain filter; // see if there's a previous instance running - otherInst = ::FindWindow(NULL, "The SWORD Project for Windows"); + otherInst = ::FindWindow(NULL, "The SWORD Project"); // if so, and we have an argument, send the argument to the other instance if (*lpCmdLine) { - if (otherInst && *lpCmdLine) { + int len = (strlen(lpCmdLine) + 1) * 5; + char *buf = new char [len + 1]; + strcpy(buf, lpCmdLine); +// filter.ProcessText(buf, len); + while (true) { + char *change = strstr(buf, "%20"); + if (change) { + change[0] = ' '; + change[1] = ' '; + change[2] = ' '; + } + else { + change = strstr(buf, "%3A"); + if (change) { + change[0] = ' '; + change[1] = ':'; + change[2] = ' '; + } + else break; + } + } + + if (otherInst != NULL) { result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "sword\\OpenVerse", NULL, "", NULL, KEY_READ | KEY_WRITE, NULL, &hkey, NULL); - result = RegSetValueEx(hkey, NULL, 0, REG_SZ, lpCmdLine, strlen(lpCmdLine) + 1); + result = RegSetValueEx(hkey, NULL, 0, REG_SZ, buf, strlen(buf) + 1); result = RegCloseKey(hkey); PostMessage(otherInst, WM_VERSE, NULL, NULL); + delete [] buf; return 0; } @@ -78,6 +103,7 @@ WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, in } chdir(dir); delete [] dir; + delete [] buf; } // adjust the registry for our private protocol using the current path @@ -97,31 +123,31 @@ WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, in /* // don't override Logos' setting if it exists result = RegOpenKeyEx(HKEY_CLASSES_ROOT, "libronixdls", 0, KEY_READ | KEY_WRITE, &hkey); - if (!result) { - char* libStr = new char[32]; - unsigned long libSize = 32; - result = RegQueryValueEx(hkey, NULL, NULL, NULL, libStr, &libSize); - if (!result) { - if (strstr(libStr, "SWORD")) { - result = 1; - } - } - } - if (result) { - result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "libronixdls", 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, "libronixdls\\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, "libronixdls\\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); - } + if (!result) { + char* libStr = new char[32]; + unsigned long libSize = 32; + result = RegQueryValueEx(hkey, NULL, NULL, NULL, libStr, &libSize); + if (!result) { + if (strstr(libStr, "SWORD")) { + result = 1; + } + } + } + if (result) { + result = RegCreateKeyEx(HKEY_CLASSES_ROOT, "libronixdls", 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, "libronixdls\\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, "libronixdls\\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); + } */ - } + } catch (Exception &exception) { Application->ShowException(&exception); } |