Page 1 of 1

#REG_MULTI_SZ ?

Posted: Fri Sep 02, 2011 1:11 pm
by SFSxOI
Anyone got something (in PB already) for reading #REG_MULTI_SZ values in the registry? I had something but it was on another drive that failed a while back and haven't needed it in a while, and now i'm missing it.

I just found out something else too, the search here on the web site kinda sucks. I wanted to search for #REG_MULTI_SZ, what I got was:

"Search found 1392 matches: +REG +MULTI

ignored: SZ"


Then I did +REG +MULTI +SZ and got:

"Search found 1392 matches: +REG +MULTI

ignored: +SZ"

tried some others too, basically the search on this web site is useless for searches like this as its too 'confined' and will not allow a lot of things.

EDIT: Never mind, I found a snippet in another project that allowed me to recreate something for getting #REG_MULTI_SZ

Re: #REG_MULTI_SZ ?

Posted: Fri Sep 02, 2011 4:20 pm
by STARGÅTE
here my code:

Code: Select all


Structure Registry_CharacterArray
	c.c[0]
EndStructure

Procedure.i GetRegistryArray(HKey.i, SubKey.s, Name.s, Array String.s(1))
	Protected *Key, Type.i, *Buffer.Registry_CharacterArray, Length.i, Index.i, LastIndex.i = -1
	If RegOpenKeyEx_(HKey, SubKey, #Null, #KEY_READ, @*Key) = #ERROR_SUCCESS
		If RegQueryValueEx_(*Key, Name, #Null, @Type, #Null, @Length) = #ERROR_SUCCESS
				*Buffer = AllocateMemory(Length)
				RegQueryValueEx_(*Key, Name, #Null, @Type, *Buffer, @Length)
				Length / SizeOf(Character) - 2
				For Index = 0 To Length
					If *Buffer\c[Index] = #Null : LastIndex + 1 : EndIf
				Next
				Length = 0
				Dim String(LastIndex)
				For Index = 0 To LastIndex
					String(Index) = PeekS(@*Buffer\c[Length])
					Length + Len(String(Index))+1
				Next
				FreeMemory(*Buffer)
		EndIf
		RegCloseKey_(*Key)
	EndIf
	ProcedureReturn LastIndex
EndProcedure
Array String.s(1) gives all Strings

EDIT: Bugfix for unicode

Re: #REG_MULTI_SZ ?

Posted: Sat Sep 03, 2011 12:58 am
by SFSxOI
Thanks for your reply STARGÅTE :)