ultravnc / UltraVNC

UltraVNC Server, UltraVNC Viewer and UltraVNC SC | Official repository: https://github.com/ultravnc/UltraVNC
https://uvnc.com
GNU General Public License v3.0
834 stars 190 forks source link

SC_20.ini isn't read in SC #228

Closed rvk01 closed 3 weeks ago

rvk01 commented 3 weeks ago

In the latest source code you added the reading of RemoveWallpaper from SC_20.ini. (I myself added the Frame too)

But it doesn't seem that SC reads the SC_20.ini at all.

In this code it seems that INIFILE_NAME is correct (SC_20.ini) but it reads it from a subdirectory UltraVNC, while SC_20.ini is supposed to be in the same directory as winvnc.exe. So I guess all those other settings for [poll] are also not read from the ini (and only the defaults are used).

    strcpy_s(m_Inifile, "");
    strcat_s(m_Inifile, path);//set the directory
    strcat_s(m_Inifile, "\\UltraVNC");
    _mkdir(m_Inifile);
    strcat_s(m_Inifile, "\\");
    strcat_s(m_Inifile, INIFILE_NAME);
    myIniFile.setIniFile(m_Inifile);
    load();

Also... at that point, the path points to C:\Users\\AppData\Local, which isn't where the SC_20.ini is located (which is extracted to %temp%). So the getting of the path above these lines (with SHGetFolderPathA) is incorrect for SC.

Edit: Something like this seems to work for me:

    strcpy_s(m_Inifile, "");
#ifndef SC_20
    strcat_s(m_Inifile, path);//set the directory
    strcat_s(m_Inifile, "\\UltraVNC");
    _mkdir(m_Inifile);
    strcat_s(m_Inifile, "\\");
#else
    if (GetModuleFileName(NULL, path, _MAX_PATH))
    {
        TCHAR* p = _tcsrchr(path, '\\');
        *p = '\0';
    }
    strcat_s(m_Inifile, path);//set the directory
    strcat_s(m_Inifile, "\\");
#endif // SC_20
    strcat_s(m_Inifile, INIFILE_NAME);
    myIniFile.setIniFile(m_Inifile);
    load();
RudiDeVos commented 3 weeks ago

Correct we are moving the ini files to a proper location (appdate / programdata), for the Sc it should be the exe folder. Still testing all changes, possible some other mistakes popup.

RudiDeVos commented 3 weeks ago

updated

rvk01 commented 3 weeks ago

updated

Yes, works correctly here now. RemoveWallpaper defaults to 1 again for SC_20. And setting it in SC_20.ini to 0 works too (showing the wallpaper).

BTW. There was also the [WALLPAPER] in helpdesk.txt. That one also still works. If I set RemoveWallpaper to 0 to hide the wallpaper, [WALLPAPER] will overrule that and show the wallpaper again. So that all works as expected.

So the setting in SC_20.ini for RemoveWallpaper wasn't strictly needed (as long as the default was 1 !!) but it might be easier and better to set these things there instead of in helpdesk.txt (because other settings like [poll] are also there). I could even add Frame myself but for now I let it show the red border (might be more clear for the other end that it is still remotely controlled).

Thnx.