Autostart

Def @Regopenkeyex(5) !"ADVAPI32","RegOpenKeyExA"
var Programm$=Par$(Par$(If((Upper$(SubStr$(Par$(0), -1, "\\"))="PROFAN.EXE") or (Upper$(SubStr$(Par$(0), -1, "\\"))="XPROFAN.EXE"),1,0)))
CLS
Set("ErrorLevel", 0)
Var AutoRun_Name$="Programm"
var check_autorun&=Create("CheckBox",%hwnd,"Programm mit Windows starten?",10,20,230,20)
case Readini$("HKEY_1","Software\\Microsoft\\Windows\\CurrentVersion\\Run",AutoRun_Name$)<>"" : SetCheck autorun&,1

WhileNot iskey(27)

    waitinput

    If getfocus(check_autorun&)

        If GetCheck(check_autorun&)=1'autorun

            Writeini "HKEY_1","Software\\Microsoft\\Windows\\CurrentVersion\\Run",AutoRun_Name$=Programm$'Autostart-Programm eintragen

        else

            DeleteRegEintrag("$80000001","Software\\Microsoft\\Windows\\CurrentVersion\\Run",AutoRun_Name$)'Autostart-Programm entfernen

        Endif

    Endif

Endwhile

Proc DeleteRegEintrag

    Parameters hkey$, schluessel$, name_eintrag$
    Declare Handle#
    Dim Handle#,4
    Declare Key#
    Dim Key#,100
    String Key#,0=schluessel$
    Declare Name#
    Dim Name#,100
    String Name#,0=name_eintrag$
    @Regopenkeyex(hkey$,Key#,0,$2,Handle#)
    External("ADVAPI32","RegDeleteValueA",Long(Handle#,0),Name#)
    External("ADVAPI32","RegCloseKey",Long(Handle#,0))
    Dispose Handle#
    Dispose Key#
    Dispose Name#

EndProc