Importing .reg files on Pocket PC.

D

David Fuchs

Hello. I've written a .NET CF application that uses the registry to store
configuration data. There are five configuration profiles for this
application - each configuration profile has a separate .REG file. In
development, when I want to switch between them, I simply click on the
appropriate .REG file in File Explorer (a dialog pops up, and I just hit OK).
This method works fine for development, however it will not suffice for
production use.

In production, I'll be deploying to Symbol mobile devices, and the last
thing I want is users clicking .REG files and interacting with registry
import dialogs. (Actually, these devices don't give users access to the file
system anyway.) As such, I need to code the application to give them a
selection and automatically import the appropriate registry data. The
question is... how?

It seems that there is no registry import tool on the Windows Mobile 5.0
devices I'm using, so I can't pass a .REG file an external process.
Additionally, I can't see any API methods that would take a .REG file and
import the settings. The registry is such an important piece of the Windows
foundation that there must be an option here I'm missing. Any
recommendations?
 
P

Paul G. Tobey [eMVP]

You're saying that you can tap on the .REG file on your debug device and
something imports those settings? If so, that *must* be a program of some
sort and all you have to do is look in the registry on the device and see
what it is and what parameters it's called with to import the file. Look in
HKCR/.reg. That should contain a reference to a class name in the default
key (maybe something like "regfile"). Look in
HKCR/<classname>/Shell/Open/Command. The default value for that key should
be the command used when you tap on the REG file in Explorer. You'll want
to do the same with Process.Create() or whatever in your code to import the
registry file.

Paul T.
 
D

David Fuchs

Ahh yes, that needs clarification - in development I'm using a tool (PHM
Registry Editor) to import the .REG files, but I don't have this tool on the
target devices, and there are no plans to deploy something like this unless
absolutely necessary.
 
P

Paul G. Tobey [eMVP]

Ah, well, no, there's nothing in the OS that does that. No API call, no
program, unless the device OEM builds one and puts it there. I thought
that's what you were saying. Our devices have one that I wrote. I'm not
aware of any source code laying around that would do it. It's a lot of
parsing...

Paul T.
 
S

Scott Gifford

But that's not to say it's hard to edit the registry from an app, just
that it's hard to do it directly from a .REG file. You can certainly
use a series of method calls to make the same changes to the registry
that the file makes.

You could probably even write a simple script to generate the
sourcecode to do that from the registry file, then just paste it in.

-----Scott.
 
P

Paul G. Tobey [eMVP]

No, it's much easier to take what you know you want in the registry and just
code it than it is to parse a .REG file and enter the data. I'm not sure
I'd try to write a "simple" script to do anything of that sort. There are a
significant number of little quirks that you end up having to handle and it
probably makes more sense to either a) actually just code the registry calls
to make the entries you want, if they are static, or b) write yourself a
parser that will take a REG file and transfer the entries to the registry.
Remember, there are dword, string, multiple string, binary, etc. types that
you have to handle and some of those can be on multiple lines in the file
with continuation characters at the ends of the lines, etc., etc.

Paul T.

Scott Gifford said:
But that's not to say it's hard to edit the registry from an app, just
that it's hard to do it directly from a .REG file. You can certainly
use a series of method calls to make the same changes to the registry
that the file makes.

You could probably even write a simple script to generate the
sourcecode to do that from the registry file, then just paste it in.

-----Scott.


"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com said:
Ah, well, no, there's nothing in the OS that does that. No API call, no
program, unless the device OEM builds one and puts it there. I thought
that's what you were saying. Our devices have one that I wrote. I'm not
aware of any source code laying around that would do it. It's a lot of
parsing...

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top