Subversion Repositories Tewi

Rev

Rev 206 | Rev 209 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 206 Rev 208
Line 1... Line 1...
1
/* $Id: main.c 206 2024-10-02 02:33:40Z nishi $ */
1
/* $Id: main.c 208 2024-10-02 02:59:59Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 71... Line 71...
71
 
71
 
72
int startup(int argc, char** argv);
72
int startup(int argc, char** argv);
73
 
73
 
74
#ifdef __MINGW32__
74
#ifdef __MINGW32__
75
char* get_registry(const char* main, const char* sub) {
75
char* get_registry(const char* main, const char* sub) {
76
	DWORD bufsize = 255;
76
	DWORD bufsize = 512;
-
 
77
	HKEY handle;
77
	char* value = malloc(256);
78
	char* value = malloc(513);
78
	int err = RegGetValue(HKEY_LOCAL_MACHINE, main, sub, RRF_RT_ANY, NULL, (void*)value, &bufsize);
79
	int err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, main, 0, KEY_QUERY_VALUE, &handle);
79
	if(err == ERROR_SUCCESS) {
80
	if(err == ERROR_SUCCESS) {
-
 
81
		err = RegQueryValueEx(handle, sub, NULL, NULL, value, &bufsize);
-
 
82
		if(err != ERROR_SUCCESS) {
-
 
83
			free(value);
-
 
84
			RegCloseKey(handle);
-
 
85
			return NULL;
-
 
86
		}
-
 
87
		RegCloseKey(handle);
80
		return value;
88
		return value;
81
	} else {
89
	} else {
82
		free(value);
90
		free(value);
83
		return NULL;
91
		return NULL;
84
	}
92
	}
Line 500... Line 508...
500
}
508
}
501
 
509
 
502
#endif
510
#endif
503
 
511
 
504
int main(int argc, char** argv) {
512
int main(int argc, char** argv) {
-
 
513
	printf("%s\n", get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir"));
505
	logfile = stderr;
514
	logfile = stderr;
506
#ifdef SERVICE
515
#ifdef SERVICE
507
	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
516
	SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}};
508
	StartServiceCtrlDispatcher(table);
517
	StartServiceCtrlDispatcher(table);
509
#else
518
#else