Namen regi

11/17/2011 21:08 _.-°Turner°-._#1
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$123 = FileRead("Regi..ini")

GUICreate("Regestrieren", 361, 42)
$Input1 = GUICtrlCreateInput($123, 72, 8, 121, 24, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER), 0)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Label1 = GUICtrlCreateLabel("Name", 8, 8, 50, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Registrieren", 200, 8, 75, 25)
$Button2 = GUICtrlCreateButton("Exit", 280, 8, 75, 25)
GUISetState(@SW_SHOW)


While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			$I1 = GUICtrlRead($Input1)
			FileDelete("Regi..ini")
			FileInstall("Regi..ini",@TempDir,"Regi..ini")
			FileWrite("Regi..ini",$I1)
		Case $Button2
			Exit

	EndSwitch
WEnd
Einbinden :
und das ist das was ich gerne eingebunden haben möchte ABER ich habe 0 ahnung wo das es funktioniert :( HELP :)
11/17/2011 22:05 lolkop#2
würde das ganze eher anders herum machen, und eine art whitelist für alles zulässige einfügen...

beispiel code:
Code:
Dim $allowed[256]
; alle zeichen verbieten
For $i=0 To 255
	$allowed[$i]=False
Next
; gewisse Zeichen zulassen
$allowed[42] = True ; *
$allowed[45] = True ; -
$allowed[46] = True ; .
$allowed[91] = True ; [
$allowed[95] = True ; _
For $i=0 To 9
	$allowed[$i+48] = True ; 0-9
Next
For $i=1 To 26
	$allowed[64+$i] = True ; A-Z
	$allowed[96+$i] = True ; a-z
Next

GUICreate("Regestrieren", 361, 42)
$input = GUICtrlCreateInput(FileRead("Regi..ini"), 72, 8, 121, 24)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlCreateLabel("Name", 8, 8, 50, 24)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
$reg = GUICtrlCreateButton("Registrieren", 200, 8, 75, 25)
$exit = GUICtrlCreateButton("Exit", 280, 8, 75, 25)
GUISetState(@SW_SHOW)

While 1
	Switch GUIGetMsg()
		Case -3, $exit
			Exit
		Case $reg
			$name = GUICtrlRead($input)
			If CheckName($name) Then
				FileDelete("Regi..ini")
				FileInstall("Regi..ini",@TempDir,"Regi..ini")
				FileWrite("Regi..ini",$name)
			Else
				MsgBox(16,"Error","Es dürfen nur A-Z , 1-9 & [ , ] , * , . , _ , - &'  Buchstaben und Zahlen benutzt werden !")
			EndIf
	EndSwitch
WEnd

Func CheckName($name)
	Local $split = StringSplit($name,'')
	For $i=0 To $split[0]
		If Not $allowed[Asc($split[$i])] Then Return False
	Next
	Return True
EndFunc