Page 1 of 1 1
Topic Options
#196043 - 2009-09-23 03:50 PM SteelKix: WriteValue()
BoForce Offline
Fresh Scripter
**

Registered: 2005-10-22
Posts: 36
Loc: Leeuwarden, The Netherlands
 Code:
;SteelKix Function: WriteValue()
;
;Author:		Boforce
;
;contributors:	None
;
;Action:		Creates a new key, adds another value-name to an existing key (and assigns it a value)
;		or changes the value of an existing value-name
;
;Syntax:		WriteValue("Key","Value","Data","Type")
;
;Version:		1.0
;
;Date:		2009-09-23
;
;Date Revised:	2009-09-23
;
;Parameters	Key
;		Required.	Identifies the key containing the value
;
;		Value
;		Optional.	Identifies the value whose data you want to discover
;			When omitted the (Default) value is used
;
;		Data
;		Required.	The data to store as the value of the entry
;
;		Type
;		Required.	Identifies the data type of the entry. The following data types are supported:
;			REG_SZ
;			REG_EXPAND_SZ
;			REG_BINARY
;			REG_DWORD
;			REG_MULTI_SZ
;
;Remarks:		None
;
;Returns:		Returns 'Command completed successfully' when successfull else an exception message
;
;Dependencies:
; SteelKix version: 0.2
; Tested with Dot Net 3.5.30729.01
; 
;Example(s):	Add string value:
;		$rc = WriteValue('HKEY_CURRENT_USER\Test','My Value','Data added','REG_SZ')
;		? 'Result  : ' + $rc
;
;Comments : This has been successfully tested on Windows XP SP3 with DOT NET 3.5.30729.01. 
;Source:
Function WriteValue($wvKey,$wvValue,$wvData,$wvType)
Dim $Win32,$DatType,$Action

Imports $Win32 = Microsoft.Win32

Select
   Case $wvType = 'REG_SZ'
	$DatType = $Win32.RegistryValueKind.String
   Case $wvType = 'REG_EXPAND_SZ'
	$DatType = $Win32.RegistryValueKind.ExpandString
   Case $wvType = 'REG_BINARY'
	$DatType = $Win32.RegistryValueKind.Binary
   Case $wvType = 'REG_DWORD'
	$DatType = $Win32.RegistryValueKind.DWord
   Case $wvType = 'REG_MULTI_SZ'
	$DatType = $Win32.RegistryValueKind.MultiString
   Case $wvType = 'REG_QWORD'
	$DatType = $Win32.RegistryValueKind.QWord
   Case $wvType = 'REG_UNKNOWN'
	$DatType = $Win32.RegistryValueKind.Unknown
EndSelect

Try
   $Action = $Win32.Registry.SetValue($wvKey,$wvValue,$wvData,$DatType)
EndTry
Catch
   $exc
EndCatch

If $exc
   $WriteValue = $exc.Message
Else
   $WriteValue = 'Command completed successfully'
EndIf
EndFunction

Top
#196094 - 2009-09-26 01:57 PM Re: SteelKix: WriteValue() [Re: BoForce]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
this udf is missing information in it's dependencies header section.
and as it's tested on development version, also summary/notes/comments section should provide with which version it was tested and proven working with.
_________________________
!

download KiXnet

Top
#196131 - 2009-09-28 09:52 PM Re: SteelKix: WriteValue() [Re: Lonkero]
BoForce Offline
Fresh Scripter
**

Registered: 2005-10-22
Posts: 36
Loc: Leeuwarden, The Netherlands
Updated the UDF.
Changed the dependency of DOT NET to the DOT NET version the UDF was tested with and added comments regarding the Os used during the test. I diddn't find any guidelines on the summary/notes/comments sections within the GuideLines(), so I jsut added what seems most applicable.

Top
#196139 - 2009-09-29 08:33 AM Re: SteelKix: WriteValue() [Re: Lonkero]
BoForce Offline
Fresh Scripter
**

Registered: 2005-10-22
Posts: 36
Loc: Leeuwarden, The Netherlands
Changed the dependencies section as suggested.
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.05 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org