Autostart

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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