REM ***********************************************
REM Title: Registry Access
REM Author: Phaelax
REM Downloaded from: http://dbcc.zimnox.com/
REM ***********************************************
 
registryPath$ = createRegistry$("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
MyDocuments$ = getRegistryValue$(registryPath$, "Personal")
 
set cursor 100,100
print "> ", MyDocuments$
 
wait key
end
 
 
 
function createRegistry$(keyPath$)
   systemPath$ = windir$()+"\system32\"
   registry$ = "c:\registry"+str$(timer())+".reg"
   command$ = "/E "+registry$+" "+chr$(34)+keyPath$+chr$(34)
 
   if file exist(registry$) then delete file registry$
   execute file "regedit.exe", command$,systemPath$,1
 
   timestamp = timer() : repeat : until file exist(registry$) OR timestamp+1000 < timer()
endfunction registry$
 
 
function getRegistryValue$(registry$, key$)
   if file exist(registry$)
      open to read 1, registry$
      fauxKey$ = chr$(34)+key$+chr$(34)+"="
      while file end(1) = 0
         value$ = readString$(1)
         if startsWith(value$, fauxKey$) = 1
            value$ = right$(value$,len(value$)-len(fauxKey$)-1)
            value$ = left$(value$,len(value$)-3)
            close file 1
            exitfunction value$
         endif
      endwhile
      close file 1
   endif
endfunction ""
 
function deleteRegistry(registry$)
   if file exist(registry$) then delete file registry$
endfunction
 
 
function readString$(fileNo)
   temp$ = ""
   z = 0
   while z <> 10
      read byte fileNo, z
      if z <> 0 then temp$ = temp$ + chr$(z)
   endwhile
endfunction temp$
 
function startsWith(string$, prefix$)
   if len(prefix$) > len(string$) then exitfunction 0
   for i = 1 to len(prefix$)
      if mid$(prefix$,i) <> mid$(string$,i) then exitfunction 0
   next i
endfunction 1