News:

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

dealing with .reg files

Started by Troy Lundin, June 08, 2006, 10:54:51 PM

Previous topic - Next topic

Troy Lundin

I have a .reg file that I want to import to the registry. How would I do this?

Ossa

I don't have one currently lying around to test with, but since you can double click as a user, I assume you mean from code. Try using ShellExecute with the appropriate parameters (I don't know if you need to specify regedit to run it or not - as I say, I don't have one to test with just atm).

Ossa
Website (very old): ossa.the-wot.co.uk

KSS

Under NT OS try (in console)REG IMPORT FileName.regor in code with use ShellExecute.

Ehtyar

Hi all. Been browsing this forum for about a fortnight now, registered just a few days ago, and this will be my first post. This topic actually fits perfectly with the first question i was planning to ask. I've been doing a fair bit of registry manipulation lately, and i've run into a similar problem to Troy. I have a very large binary value that i need to add to the regisrty, but the length of the string exceeds 255 chars. I was wondering if anyone had any suggestions how how to insert it using the registry api, instead of shellexecute (what im currently using). Any help would be greatly appreicated, thanks  :bg
P.S. GREAT forum, the examples and people on this forum are absolutely priceless for any assembly coder  :U :U

donkey

If you are looking to deal with .reg files programatically, you can use the following (GoAsm syntax)

MergeToRegistry FRAME pRegFile
uses ebx
LOCAL RegExitCode :D
LOCAL RegCmdLine[MAX_PATH] :B

/*
Merges the supplied .reg file into the registry using RegEdit

This procedure requires a fully qualified path !
*/

invoke ZeroMem,OFFSET RegCmdLine,MAX_PATH

invoke GetWindowsDirectory,OFFSET RegCmdLine,MAX_PATH

invoke szCatStr,OFFSET RegCmdLine,OFFSET RegString
mov al,[pRegFile]
cmp al,22h
je >
invoke StrLen,OFFSET RegCmdLine
lea edx,RegCmdLine
add eax,edx
mov B[eax],22h
:
invoke szCatStr,OFFSET RegCmdLine,[pRegFile]
invoke StrLen,OFFSET RegCmdLine
lea edx,RegCmdLine
add eax,edx
mov cl,[eax-1]
cmp cl,22h
je >
mov B[eax],22h
:
mov D[sui.cb],SIZEOF STARTUPINFO
invoke GetStartupInfo,OFFSET sui
xor eax,eax
invoke CreateProcess,NULL,OFFSET RegCmdLine,eax,eax,\
TRUE,eax,eax,eax,OFFSET sui,OFFSET pi
or eax,eax
jz >.ERROR

/*
Wait until the app has finished before continuing
*/

invoke WaitForSingleObject,[pi.hProcess],INFINITE
invoke GetExitCodeProcess,[pi.hProcess],OFFSET RegExitCode
invoke CloseHandle,[pi.hProcess]
invoke CloseHandle,[pi.hThread]

mov eax,[RegExitCode]
ret

.ERROR
mov eax,-1
ret


RegString: DB "\RegEdit.exe /S ",0

ENDF
"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