Creating key entries in the registry

I need to write to the registry from Navision, but not having done it before I’m not sure how to proceed. I have looked at the automation object ‘KeyGeneration 1.0 Type Library’ which has the classes of CoKeyGeneration & IKeyGeneration but again not sure of how to use them. Has anyone done something along this line who could give me some advise (other than don’t do it) of how to go about it. Examples would be great. Thanks David

Hey David, because we needed such a functionality I wrote a small automation object which provides two function one to read and one to write into the registry. If you want I can provide this automation object to you.[:)]

Could you be so kind to give me some examples of when it is needed to write to the registery ? what is done when the customer upgrades to a new operating system, do you need to redo some code than ?

Hey The program is a small automation control, (Setregistry.dll), you have to register it before you can use it, it works (so far) under Win98, WinNT, W2000. After you have register it you have to define a variable as a automation control in your navision application (report, codeunit…). Afterwards you can write into the registry using this variable. Example define variable “registry” as Automation Control type SetRegistryKey. in the program you can than write into the registry by using the variable registry : … registry.SetKeyValue(HKEY_CLASSES, Software\Microsoft\Office\9.0,Path,C:\pdfpool,1). … In this example you write into the registry the follwing values under the class "HKEY_CLASSES into the Classtree "“Software\Microsoft\Office\9.0” using the key “Path” the value “c:\pdfool” as a REG_SZ. [:)]

Just a quick note about automation objects; they can be very useful in doing small things such as this but can stop you in your tracks if you have to fix something on a machine without the object. So create a codeunit that is used as an interface between navision and the automation object/OCX. just add a function for each call in the object and always call the functions in the codeunit within Navision. Paul Baxter

That’s just what I’m looking for. If you would not mind I would like a copy please.

quote:


Originally posted by FredBergmann
Hey The program is a small automation control, (Setregistry.dll), you have to register it before you can use it, it works (so far) under Win98, WinNT, W2000. After you have register it you have to define a variable as a automation control in your navision application (report, codeunit…). Afterwards you can write into the registry using this variable. Example define variable “registry” as Automation Control type SetRegistryKey. in the program you can than write into the registry by using the variable registry : … registry.SetKeyValue(HKEY_CLASSES, Software\Microsoft\Office\9.0,Path,C:\pdfpool,1). … In this example you write into the registry the follwing values under the class "HKEY_CLASSES into the Classtree "“Software\Microsoft\Office\9.0” using the key “Path” the value “c:\pdfool” as a REG_SZ. [:)]


To print to the PDFWriter printer within an automated process the destination file name has to be recorded in the win.ini file or the registry depending on which operating system is installed. This then avoids a user having to specify the file name each time. The keys I’m writing to are for the PDFWriter and the codeunit I have written, based on a word macro I already have working, checks the operating system to see if the ini file or registry should be updated.

quote:


Originally posted by gco
Could you be so kind to give me some examples of when it is needed to write to the registery ? what is done when the customer upgrades to a new operating system, do you need to redo some code than ?


Thanks for that. That’s one I came across some time ago but worth keeping in mind.

quote:


Originally posted by triff
Just a quick note about automation objects; they can be very useful in doing small things such as this but can stop you in your tracks if you have to fix something on a machine without the object. So create a codeunit that is used as an interface between navision and the automation object/OCX. just add a function for each call in the object and always call the functions in the codeunit within Navision. Paul Baxter


Hey David, send me your email address to Friedhelm.Bergmann@coperion.com. I will then send you the tool back. Fred

Hello Peeps, I’ve spent ages searching for a decent (and free) Registry Editting OCX so please let me have a copy as well!!! If you (or your customer) can’t use OCXs however then Microsoft has a command line registry editor (REG.EXE) which is installed in XP as standard or can be downloaded as part of the NT Resource Kit. You can then use SHELL to update the registry for you. Not pretty but it works Regards