Source language: Translate to:

Reading registry

NeoBook tips, tricks, code samples and more...

Moderator: Neosoft Support

Reading registry

Postby lsaini » Thu Sep 08, 2005 12:53 pm

Hi there !!!

one of my needs is discover the keys (or hive... i never know the correct name...) under another one. i'll try explain:

under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix have a lot of folders with installed hotfix.
well, my need is list in txt file or put in a variable that list of the folder names.

can someone help me ?

thanks in advance !!!

Luis Elias
Sao Paulo - Brazil
User avatar
lsaini
 
Posts: 3
Joined: Thu Sep 08, 2005 6:54 am
Location: São Paulo - Brazil

Postby Gaev » Thu Sep 08, 2005 4:24 pm

Luis Elias:

Welcome to the forum.

Regedit, the Windows program that manages the Registry contents, can be called in command-line mode to "export" the contents of any specified hive (folder and all its subfolders) to a named text file.

First, try this command interactively ...

regedit /E c:\exportedReg.txt "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix"

... note:

a) regedit is the program name on my WIn98/SE machine ... could be different under other versions of Windows

b) start off by using a simple file name (no spaces in name or folder) ... if you need to specify spaces, try enclosing in double quotes.

c) as long as the content of the hive is not larger than 64 KB, you should be able to see it with notepad.exe ... otherwise use wordpad.exe or some other text editor program.

Once you are satisfied that this works on your machine, you can invoke it from within your pub using the Run command ... read the help file for all the options NeoBook provides with this command ... in particular, you can set it to wait until the regedit program does its (export) thing ... you can then follow it up with another Run command (notepad.exe) ... or use NeoBook's FileRead commands to load the contents of the file into memory/variables ... ask here if you have difficulties with the commands.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby lsaini » Tue Sep 13, 2005 9:42 am

Hi Gaev,

first, thanks for your kindness.
it works fine, but i'm still looking for an internal programmed solution
:idea: including many other registry keys.

you're fantastic! thanks a lot!

Luis Elias
User avatar
lsaini
 
Posts: 3
Joined: Thu Sep 08, 2005 6:54 am
Location: São Paulo - Brazil

Postby Gaev » Tue Sep 13, 2005 10:43 am

Luis Elias:
... but i'm still looking for an internal programmed solution including many other registry keys.
I am not sure I understand ...

a) What is the difference between your script doing some plug-in command like ...
Code: Select all
xxGetRegData "[myRegKeyRoot]" "[myRegData]"
... and issuing a command like ...
Code: Select all
Run "regedit" "/E [myTempFile] [#34][myRegKeyRoot][#34]" "Wait+Hidden" "RegExtractDone" ""
... and a subroutine like ...
Code: Select all
:RegExtractDone
FileRead "[myTempFile]" "All" "[myRegData]"
FileErase "[myTempFile]"
Return

b) What do you mean by including many other registry keys ?
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby lsaini » Tue Sep 13, 2005 11:55 am

Hi Gaev,

a) i didn't have that idea... sorry about my poor scripting !!! :oops:
i'm a rookie prog, but i'm in love with neobook!!!

b) sorry for my poor explanation:
the "other" registry keys is about other registry stuff like:
NtfsDisable8dot3NameCreation
AutoShareServer
NotificationPackages
...etc... security stuff to preview and mantain...

again... You are Fantastic!!! i'm scripting your tip now!!!
working or not i'll answer you.

thanks a lot,

Luis Elias
Luis Elias
Sao Paulo - Brazil
User avatar
lsaini
 
Posts: 3
Joined: Thu Sep 08, 2005 6:54 am
Location: São Paulo - Brazil

How to get various but interesting and useful infos ?

Postby Morpheus » Thu Nov 10, 2005 6:26 am

Hi,

I tried to read som reg. keys but unfortunately there are various between WinXp and e.g. WnME...

I'd like to ask you for help, how to get various but interesting and useful infos , like wich Oper. System user has, which CPU speed and how big is his RAM memory ?

Why to know ?

If I made a 'strong' as for CPU application, where a better PC is needed, I offer/use e.g. more quality video or whatever stuff OR I use a light version stuf...

Simply not to cause user's PC get down... ;-)

Thanks for help and tips.


M.
Last edited by Morpheus on Thu Nov 10, 2005 7:55 am, edited 1 time in total.
____________
Keep smiling !
____________
User avatar
Morpheus
 
Posts: 19
Joined: Wed Nov 09, 2005 5:11 am
Location: Europe

Postby Gaev » Thu Nov 10, 2005 7:17 am

Morpheus:
I'd like to ask you for help, how to get various but interesting and useful infos , like wich Oper. System user has, which CPU spped and how big is his RAM memory ?
NeoBook provides a convenient way of obtaining information about user's operating environment via "Reserved Global Variables" ... reproduced from the Help file ...
Windows/Hardware:

[CDRomDrive] - Drive letter of the first CD-ROM drive or “error” if none.
[HDSerialNum] - Returns the serial number for the system's C: drive.
[NetworkDrive] - Drive letter of the first network drive or “error” if none.
[ScreenColors] - The number of colors supported by the current Windows video mode.
[ScreenHeight] - The height the entire Windows screen in pixels.
[ScreenWidth] - The width of the entire Windows screen in pixels.
[SystemLanguage] - Returns the active system locale. For example: “English (United States)”
[UserName] - The name of the currently logged in user (if a network is installed).
[WindowsPlatform] - The current Windows platform installed (Windows 95, 98, ME = 1, Windows NT, 2000, XP = 2).
[WindowsVer] - The major and minor Windows version number (4.0 for Windows 95, 5.1 for Windows XP).
... don't have knowledge about where exactly the processor type/model/speed and memory size are stored.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Thanks anyway... ;-)

Postby Morpheus » Thu Nov 10, 2005 7:51 am

Gaev wrote:Morpheus:
I'd like to ask you for help, how to get various but interesting and useful infos , like wich Oper. System user has, which CPU spped and how big is his RAM memory ?
NeoBook provides a convenient way of obtaining information about user's operating environment via "Reserved Global Variables" ... reproduced from the Help file ...
Windows/Hardware:

[CDRomDrive] - Drive letter of the first CD-ROM drive or “error” if none.
[HDSerialNum] - Returns the serial number for the system's C: drive.
[NetworkDrive] - Drive letter of the first network drive or “error” if none.
[ScreenColors] - The number of colors supported by the current Windows video mode.
[ScreenHeight] - The height the entire Windows screen in pixels.
[ScreenWidth] - The width of the entire Windows screen in pixels.
[SystemLanguage] - Returns the active system locale. For example: “English (United States)”
[UserName] - The name of the currently logged in user (if a network is installed).
[WindowsPlatform] - The current Windows platform installed (Windows 95, 98, ME = 1, Windows NT, 2000, XP = 2).
[WindowsVer] - The major and minor Windows version number (4.0 for Windows 95, 5.1 for Windows XP).
... don't have knowledge about where exactly the processor type/model/speed and memory size are stored.



Thanks for your reply, I forgot to chcek the global vars :oops:

And as for other infos I'm thinking - as u might know there are many freew. hardware utilities which check your hardware stuff, so the q. is: how do they check it ? :o

It must be then checked out in/by NB also, right ? 8)


Have a nice day !


M.
____________
Keep smiling !
____________
User avatar
Morpheus
 
Posts: 19
Joined: Wed Nov 09, 2005 5:11 am
Location: Europe

Postby Gaev » Thu Nov 10, 2005 9:59 am

Morpheus:

Some more information ...

a) Memory:

AutoIt has this function ... $array = MemGetStats() ... which will return array items ...

$array[0] = Memory Load (Percentage of memory in use)
$array[1] = Total physical RAM
$array[2] = Available physical RAM
$array[3] = Total Pagefile
$array[4] = Available Pagefile
$array[5] = Total virtual
$array[6] = Available virtual

... so you can compile a (tiny) exe using this (free) software ... and then Run it from inside your NeoBook application ... the returned information can be stored in a temp file which NeoBook can then FileRead.

b) Processor:

This web page ... http://www.imt.net/~joe/matt/program/vb ... 7/8/86.TXT ... shows how one would use VisualBasic to get required information ... more importantly, it references the Windows API calls needed to obtain the necessary information.

Alternately, you can design your own "calibration tool" ... in other words, see how many loops this code goes through on your machine(s) in a given time ...
Code: Select all
SetVar "[WhileCounter]" "0"

SetVar "[Timer1Flag]" ""
TimerStart "Timer1" "5000"

While "[Timer1Flag]" "=" ""
     SetVar  "[WhileCounter]" "1+[WhileCounter]"
EndWhile
... and in your Timer's Interval Section ...
Code: Select all
SetVar "[Timer1Flag]" "Stopped"
TimerStop "Timer1"
...and compare your [WhileCounter] with user's experience to get an idea of the processing power of his machine.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Morpheus » Thu Nov 10, 2005 12:50 pm

Hi again,

I've started to look at the autoit, also got hpwautoit plug and was seeeking the function in autiot help file, but I didn't find any like u've described...
:roll:


Gaev wrote:
a) Memory:

AutoIt has this function ... $array = MemGetStats() ... which will return array items ...

$array[0] = Memory Load (Percentage of memory in use)
$array[1] = Total physical RAM
$array[2] = Available physical RAM
$array[3] = Total Pagefile
$array[4] = Available Pagefile
$array[5] = Total virtual
$array[6] = Available virtual

... so you can compile a (tiny) exe using this (free) software ... and then Run it from inside your NeoBook application ... the returned information can be stored in a temp file which NeoBook can then FileRead.




Could you please describe a little more how to make such autiot script ?
I've downloaded autoit too so I can convert the script to an .exe file but I have no idea how to write such script... :shock:
:(

I just write in php, javascript a little and now studying NB5 stuff 8)

So, I'd need just the scipt with a known output variable, which could be returned or a file with results would be created so I could load it to NB...


Thanks for help in advance !




M.
____________
Keep smiling !
____________
User avatar
Morpheus
 
Posts: 19
Joined: Wed Nov 09, 2005 5:11 am
Location: Europe

Well, I found tha what u've been talking about...

Postby Morpheus » Thu Nov 10, 2005 1:14 pm

Hi again :D

I've been screwing into manuals etc. and finally found that what u dwscribed, yes I've found it in a chm help file and made my first autoitscript !

:D

-code-
$mem = MemGetStats()
MsgBox(0, "Total physical RAM (KB):", $mem[1])
-code-

it's been easy but - now seriously - how to use it with coop. w. NB ?
I can make the .exe from the scipt but I'd need cooperate with NB, so I'd need to make a file with array variable, not a MsgBox....

Simply, use the result of the information to be able to load it as a variable in NB...


Any suggestions, pls ?
:?

If I foind any, I'll let u know about that...
:)


Cross fingers or pls help...
Thanx.


M.
____________
Keep smiling !
____________
User avatar
Morpheus
 
Posts: 19
Joined: Wed Nov 09, 2005 5:11 am
Location: Europe

Postby Gaev » Thu Nov 10, 2005 4:40 pm

Morpheus:

I am not familiar with Hans-Peter's plug-in ... if MemGetStats() is available from his plug-in (which I believe works with AutoIt v2), he should be able to assist you (I understand he is out of town this week).

In the mean time, you can try running this AutoIt script ...
Code: Select all
$mem = MemGetStats()
$file = FileOpen("memory.txt", 1)
; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
FileWrite($file, $mem[1])
FileClose($file)
... which will write the result to a file called memory.txt

Just place these commands in a file with the .au3 file extension ... say GetMemory.au3 ... and double click on its entry in Windows Explorer. Once you are satisfied that this script works in an interpreted environment, compile it (say GetMemory.exe) ... and make sure the .exe behaves in a similar fashion.

Now invoke this .exe file from within your NeoBook .pub ... something like ...
Code: Select all
SetVar "[memfile]" "[PubDir]memory.txt"

FileExists "[memfile]" "[fileExists]"
If "[fileExists]" "=" "True"
    FileErase "[memfile]"
EndIf

Run "[PubDir]GetMemory.exe" "" "Wait+Hidden" "" ""

FileRead "[memfile]" "All" "[UserMemory]"
... [UserMemory] should then contain the required value.
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Cipolla » Fri Nov 11, 2005 1:59 am

Hello,

there exists a plugin from Alberto Meyer called tmHelper. There are many functions for reading system informations, including cpu and memory. Here is a list of the functions:

Code: Select all
0: ComputerDescription
1: ComputerName
2: ComputerWorkgroup
3: CurrentUserName
4: WinDirectXVersion
5: DefaultBrowser
6: DirCache
7: DirCookies
8: DirCommonFiles
9: DirDesktop
10:DirFavorites
11:DirFavoritesAll
12:DirFonts
13:DirHistory
14:DirMedia
15:DirMyPictures
16:DirNetHood
17:DirPersonal
18: DirPrintHood
19: DirProgramFiles
20: DirPrograms
21: DirProgramsAll
22: DirRecent
23: DirSendTo
24: DirStartMenu
25: DirStartMenuAll
26: DirStartup
27: DirStartupAll
28: DirSystem
29: DirTemp
30: DirTemplates
31: DirTemplatesAll
32: DirWindows
33: DiskCSerialNumberStr
34: OwnerName
35: OwnerCompany
36: CPUIdentifier
37: CPUVendor
38: ScreenSaver
39: SystemPathes
40: WinProductID
41: WinProductName
42: WinVersion
43: WinVersionNumber
44: VersionSubNumber
45: DiskCSerialNumber
46: MemAvailPhisical
47: MemAvailVirtual
48: MemTotalVirtual
49: MemLoad
50: CPUsNumber
51: CPUFrequency
52: SystemUpTime
53: WinVersionBuild
54: WinVersionMajor
55: WinVersionMinor


I believe it was freeware, but i could not find it on al´s page. Maybe contact him for this plugin or Alberto if you read this you can post a link if it is still available.

For Registry manipulation i can suggest rlFunctions from Reynoldlariza. It could be found here:

http://reynoldlariza.bizhat.com/

There is also a good demo file to show how it works. And it is freeware.
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Postby Morpheus » Fri Nov 11, 2005 3:41 am

Cipolla wrote:Hello,

there exists a plugin from Alberto Meyer called tmHelper. There are many functions for reading system informations, including cpu and memory. Here is a list of the functions:

.
.
.


Hi,

thanks all for your suggestions, I'll chcek them out and let you know, how I decided to solve this...

Now, almost all the day and night :D (I got like it the programming :D )
I've been working with AutoIt and made already an .exe app where I get the RAM memory's infos
(BTW the code is small let the .exe is small too)

-AutoIt code-
Code: Select all
#include <Array.au3>

$mem = MemGetStats()

Dim $sysinfos = _ArrayToString($mem,"|")
ClipPut($sysinfos)


$mem is an array of the information of RAM, e.g. $mem[0] is RAM usage, 1 is RAM total etc.
and
this ClipPut($sysinfos)
is adding the info to clipboard because if user has no admin rights, any file won't be able to be created...
After running the .exe by calling it in NB I just get the data from Clipboard and separate it (they're delimited by "|" -
the command Dim $sysinfos = _ArrayToString($mem,"|") in the AutoIt script).

So, now I'll try to get the CPU clock frequency, however when I'll finish it, I'll place the .exe file on the web (the .exe would just produce only some system info, in a format like - just one line

72|523764|143920|1275620|889992|2097024|2065292

(this is my actual info, which says:
72 % usage of my RAM just now, 523764 KB my total RAM, 143920 kB is my free RAM to use and other are about virtual paging etc....)

So, once more, thank you all for tips and suggestions, I'll let you know if I'll make an universal solution, which could use other neo-friends also and as well I'll chcek the Cipolla's suggestion if it's the easiest... :)


M.
____________
Keep smiling !
____________
User avatar
Morpheus
 
Posts: 19
Joined: Wed Nov 09, 2005 5:11 am
Location: Europe

Postby Gaev » Fri Nov 11, 2005 6:15 am

Morpheus:

Yes, the Clipboard can be another vehicle for passing data between programs ... however, in order to ensure that this data is not overwritten by other programs between the time it is placed in the clipboard and pasted into your NeoBook application (however remote this possibility), you might want to "add your own signature to this data" e.g.
Code: Select all
#include <Array.au3>

$mem = MemGetStats()

Dim $sysinfos = _ArrayToString($mem,"|")

ClipPut("Morpheus says your answer is ... "+$sysinfos)
... so your application can ensure the clipboard data is from the expected source.

You can also expand this so when this (or another) AutoIt script/program encounters an error, you can ...
Code: Select all
ClipPut("Morpheus says your answer is ... ERROR! ERROR: Something Really Bad Happened")
User avatar
Gaev
 
Posts: 3733
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Next

Return to NeoBook Knowledgebase

Who is online

Users browsing this forum: No registered users and 1 guest