News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

General question about accessing the system registry

Started by Shooter, December 19, 2010, 10:44:34 PM

Previous topic - Next topic

dedndave

now - take it a step further
invoke RegQueryValueEx twice

the first time, set the buffer length to 0
then, the function will tell you how many bytes you need
add 1 for the null terminator, round it up to the next 4-even value and allocate stack space for the value

then, invoke it a second time to get the value
now, you have a dynamic allocation

when you are done - close the reg handle and deallocate the stack space

Gunner

You do know Regedit has command line switches that allow you to save a key to a .reg file and import it?!

So, on the old computer you could do:
regedit /E c:\hklm_run.reg "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" and it will export the list of Startup programs from the Run section. of course change this to the key you want exported

and on the new computer do:
regedit c:\hklm_run.reg

of course you could write a little app with shellexecute or something to do this for you...
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave


Shooter

Well, I intend to have the autorun proggy test a few registry values to determine if the computer has been set up before, then conditionally either grab the info, or set it. There are some device drivers that are proprietary which will need to be installed on the new computer and I'm hoping to be able to get that done as well.

By the way, here's my working copy of my project.
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Shooter

OK, I might need a little guidance on this one.

In order to retrieve the network settings such as IP address and status, you have to first retrieve the SID of the CardType in Software, but in my particular case they're in subkeys 13, 3, and 4. I know when retrieving files in a disk folder you can set up a LOOPNZ to retrieve the next file name. Is there something like that for the registry?

After getting all of the SID's you have to find the subkeys for using those SID's as the CardType in the System\CurrentControlSet\Services to get more information, which is where the IP address and NETWORK ID are stored.

It gets a wee bit complicated, at least for me. Any pointers?

Thanks,
-Shooter

Ref:
Quote"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\(some number)\ServiceName"

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\EnableDHCP"

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\DHCPIPAddress"

"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & CardType & "\Parameters\Tcpip\IPAddress"
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

not at computer so no code...  search for RegEnumKeyEx and RegEnumValueEx
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave

 :bg
        .XCREF
        .NOLIST
        INCLUDE    \masm32\include\masm32rt.inc
        .LIST

        .DATA

CNameSize  dd MAX_COMPUTERNAME_LENGTH+1

        .DATA?

CompName   db (MAX_COMPUTERNAME_LENGTH+1) dup(?)

        .CODE

_main   PROC

        INVOKE  GetComputerName,offset CompName,offset CNameSize
        print   offset CompName
        print   chr$(13,10)

        inkey
        exit

_main   ENDP

        END     _main


see attached program...

Shooter

Dave,
Wow, I didn't know about GetComputerName. I see there's also a SetComputerName. Is there something like GetCurrentIP, or GetDomainName??

Where might I find documentation on MAX_COMPUTERNAME_LENGTH?

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

dedndave

http://msdn.microsoft.com/en-us/library/ms724953%28v=VS.85%29.aspx

MAX_COMPUTERNAME_LENGTH = 15
it is in windows.inc

however - some functions may return longer strings if they allow for full DNS names

Shooter

Quote from: dedndave on December 23, 2010, 04:44:12 AM
http://msdn.microsoft.com/en-us/library/ms724953%28v=VS.85%29.aspx

Hey thanks, Dave! That's going to save me all kinds of time for research.

I just wished there was better documentation on it. I looked up GetSystemInfo and there wasn't a lot of information about it on MSDN's website.  :(

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

donkey

Quote from: Shooter on December 23, 2010, 03:34:53 AM
Dave,
Is there something like GetCurrentIP, or GetDomainName??

Use the host name returned from gethostname to get the IP address using gethostbyname. Be sure to call WSAStartup before trying to call any WinSock function and WSACleanup when your all done.

If you're using GoAsm, use #include WinSock2.h for the necessary structures and libraries.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

for MASM...
        INCLUDE    \masm32\include\ws2_32.inc
        INCLUDELIB \masm32\lib\ws2_32.lib

Shooter

Side question not related to this thread, but it's about something that was IN this thread:

How do I create a hyperlink that acts like yours in this:
QuoteUse the host name returned from gethostname to get the IP address using gethostbyname. Be sure to call WSAStartup before trying to call any WinSock function and WSACleanup when your all done.

Every time I try to use the "Insert Hyperlink" thing, it only works when I put the entire http address in. I can't figure out how to make it so that one word is the actual hyperlink.

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

donkey

[URL=some url here]Text to be shown[/URL]

For more information about tags check the BBCode primer.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

also handy is the Help button just below the Search window
it has only the codes that work in this forum

http://www.masm32.com/board/Themes/default/help/posting.english.html#bbcref