1 | #include <windows.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <string.h>
|
---|
5 | #include <memory.h>
|
---|
6 | #pragma hdrstop
|
---|
7 |
|
---|
8 | int __stdcall WinMain(HANDLE Instance, HANDLE /*PrevInstance*/, LPSTR CmdLineStr, int /*CmdShow*/) {
|
---|
9 | HKEY hk1, hk2, hk3, hk4, hk5, lk;
|
---|
10 | char command[2048];
|
---|
11 | command[0] = '\0';
|
---|
12 |
|
---|
13 | // try to find the command to start the library
|
---|
14 | if (RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE", &hk1) == ERROR_SUCCESS) {
|
---|
15 | if (RegOpenKey(hk1, "Waikato University", &hk2) == ERROR_SUCCESS) {
|
---|
16 | if (RegOpenKey(hk2, "FAO", &hk3) == ERROR_SUCCESS) {
|
---|
17 | if (RegOpenKey(hk3, "1", &hk4) == ERROR_SUCCESS) {
|
---|
18 | if (RegOpenKey(hk4, "1.00.000", &hk5) == ERROR_SUCCESS) {
|
---|
19 |
|
---|
20 | if (RegOpenKey(hk3, "1.00.000", &lk) == ERROR_SUCCESS) {
|
---|
21 |
|
---|
22 | // look for the command to start the browser
|
---|
23 | DWORD dwIndex = 0;
|
---|
24 | char key[256];
|
---|
25 | key[0] = '\0';
|
---|
26 | DWORD keysize = 256;
|
---|
27 | DWORD type;
|
---|
28 | DWORD comsize = 2048;
|
---|
29 | while (RegEnumValue(lk, dwIndex, key, &keysize, NULL, &type,
|
---|
30 | (unsigned char *)command, &comsize) == ERROR_SUCCESS) {
|
---|
31 | // see if this is the right key
|
---|
32 | if (strcmp (key, "library") == 0) break;
|
---|
33 | else command[0] = '\0';
|
---|
34 |
|
---|
35 | // prepare for next iteration
|
---|
36 | dwIndex++;
|
---|
37 | keysize = 256;
|
---|
38 | comsize = 2048;
|
---|
39 | }
|
---|
40 | RegCloseKey(lk);
|
---|
41 | }
|
---|
42 | RegCloseKey(hk5);
|
---|
43 | }
|
---|
44 | RegCloseKey(hk4);
|
---|
45 | }
|
---|
46 | RegCloseKey(hk3);
|
---|
47 | }
|
---|
48 | RegCloseKey(hk2);
|
---|
49 | }
|
---|
50 | RegCloseKey(hk1);
|
---|
51 | }
|
---|
52 |
|
---|
53 | if (strlen (command) == 0) {
|
---|
54 | // not installed, try to run the setup program
|
---|
55 | WinExec ("setup.exe", SW_SHOW);
|
---|
56 | } else {
|
---|
57 | // installed ask the user whether they want to run the library now
|
---|
58 | if (MessageBox (NULL,
|
---|
59 | "Would you like to run the FAO Library?",
|
---|
60 | "Greenstone Digital Library",
|
---|
61 | MB_YESNO) == IDYES) {
|
---|
62 | WinExec (command, SW_SHOW);
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | return 0;
|
---|
67 | }
|
---|