From 6d164fc0a2586cf718a0df7b2eb39b23208aa41a Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 2 Oct 2024 02:59:59 +0000 Subject: [PATCH] do this instead git-svn-id: file:///raid/svn-personal/tewi/trunk@208 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Server/install.nsi | 13 ++++++++++++- Server/main.c | 15 ++++++++++++--- installer.sh | 12 ++++++------ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Server/install.nsi b/Server/install.nsi index e3c7bc4..e50b239 100644 --- a/Server/install.nsi +++ b/Server/install.nsi @@ -22,6 +22,7 @@ LangString SERV_TOO ${LANG_JAPANESE} "サービスもインストールする(NT LangString WAIT_STOP ${LANG_ENGLISH} "Waiting for 1 second so service can stop" LangString WAIT_STOP ${LANG_JAPANESE} "サービスが止まるのを待っています" +!include "x64.nsh" !include "LogicLib.nsh" !include "Sections.nsh" @@ -57,8 +58,13 @@ Section CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Start Tewi HTTPd (verbose).lnk" "$INSTDIR\bin\tewi.exe" "-v" CreateShortcut "$SMPROGRAMS\Tewi HTTPd\Uninstall Tewi HTTPd.lnk" "$INSTDIR\uninstall.exe" "" + ${If} ${RunningX64} + SetRegView 64 + ${Else} + SetRegView 32 + ${EndIf} WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "DisplayName" "Tewi HTTPd" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "InstallDir" '"$INSTDIR"' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "InstallDir" "$INSTDIR" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteUninstaller "$INSTDIR\uninstall.exe" @@ -125,5 +131,10 @@ Section "Uninstall" RMDir /r "$INSTDIR" RMDir /r "$SMPROGRAMS\Tewi HTTPd" + ${If} ${RunningX64} + SetRegView 64 + ${Else} + SetRegView 32 + ${EndIf} DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tewi HTTPd" SectionEnd diff --git a/Server/main.c b/Server/main.c index 4b3c832..cece19b 100644 --- a/Server/main.c +++ b/Server/main.c @@ -73,10 +73,18 @@ int startup(int argc, char** argv); #ifdef __MINGW32__ char* get_registry(const char* main, const char* sub) { - DWORD bufsize = 255; - char* value = malloc(256); - int err = RegGetValue(HKEY_LOCAL_MACHINE, main, sub, RRF_RT_ANY, NULL, (void*)value, &bufsize); + DWORD bufsize = 512; + HKEY handle; + char* value = malloc(513); + int err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, main, 0, KEY_QUERY_VALUE, &handle); if(err == ERROR_SUCCESS) { + err = RegQueryValueEx(handle, sub, NULL, NULL, value, &bufsize); + if(err != ERROR_SUCCESS) { + free(value); + RegCloseKey(handle); + return NULL; + } + RegCloseKey(handle); return value; } else { free(value); @@ -502,6 +510,7 @@ void show_png(void) { #endif int main(int argc, char** argv) { + printf("%s\n", get_registry("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Tewi HTTPd", "InstallDir")); logfile = stderr; #ifdef SERVICE SERVICE_TABLE_ENTRY table[] = {{"Tewi HTTPd", servmain}, {NULL, NULL}}; diff --git a/installer.sh b/installer.sh index 768855a..f2a840b 100755 --- a/installer.sh +++ b/installer.sh @@ -22,13 +22,13 @@ VERSION=`make get-version` sed "s/undef NO_SSL/define NO_SSL/g" config.h.tmpl > config.h make clean || fail -make PLATFORM=$1 PREFIX=C:/srv/Tewi -j4 || fail +make PLATFORM=$1 PREFIX=C:/Tewi -j4 || fail cp Server/tewi.exe tewi.exe make clean || fail -make PLATFORM=$1-service -j4 PREFIX=C:/srv/Tewi || fail +make PLATFORM=$1-service -j4 PREFIX=C:/Tewi || fail cp Server/tewi.exe tewi-service.exe cd Server -../Tool/genconf "C:/srv/Tewi" modules dll > ../generated.conf +../Tool/genconf "C:/Tewi" modules dll > ../generated.conf ../Tool/itworks > ../itworks.html makensis -DVERSION=$VERSION install.nsi cp install.exe ../install-nossl.exe @@ -38,13 +38,13 @@ cd .. sed "s/define NO_SSL/undef NO_SSL/g" config.h.tmpl > config.h make clean || fail -make PLATFORM=$1 -j4 PREFIX=C:/srv/Tewi|| fail +make PLATFORM=$1 -j4 PREFIX=C:/Tewi|| fail cp Server/tewi.exe tewi.exe make clean || fail -make PLATFORM=$1-service -j4 PREFIX=C:/srv/Tewi || fail +make PLATFORM=$1-service -j4 PREFIX=C:/Tewi || fail cp Server/tewi.exe tewi-service.exe cd Server -../Tool/genconf "C:/srv/Tewi" modules dll > ../generated.conf +../Tool/genconf "C:/Tewi" modules dll > ../generated.conf ../Tool/itworks > ../itworks.html makensis -DVERSION=$VERSION install.nsi cp install.exe ../install-ssl.exe -- 2.43.0