More on OLE attachments and record notes

October 2, 2009

Microsoft’s David Musgrave takes on OLE attachments and record notes based on a support case he tackled recently. David reviews the process use by Dynamics GP to retrieve the next note index value and how the system associates the note to a record. He explores the OLE container and how the file names are encoded along with the path.

Furthermore, he provides some Dexterity and SQL code to demonstrate how you would retrieve the hexadecimal value used to compose the notes file name. Be sure to read David’s article to get the complete scoop.


Related articles

All About the Dexterity OLE Container – click here
Understanding Notes and the Note Index Field @ Developing for Dynamics GP, click here

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/


The Technology Corner: Windows 7 and Microsoft Dynamics GP 10.0

September 20, 2009

For those of you who follow me on Facebook and Twitter, you probably already got first hand updates as I was going through rebuilding my laptop with the new Windows 7 and getting all my core applications installed. Most of you are aware that I am more of a technical guy, so hardware and applications performance is very critical.

Let’s start with my laptop… I currently own a Dell XPS M1710 running Intel Centrino Duo core and 2.5GB in RAM. I know, yes! I use a gaming notebook taking advantage of the processing capabilities and the massive 17″ screen. A little outdated when compared to the new XPS, but it still gets the job done!

The goal was to install the following software:

  • Windows 7 Enterprise
  • Microsoft Office 2007 Enterprise, including Microsoft Project 2007 and Microsoft Visio 2007
  • Microsoft SQL Server 2008 Standard with Service Pack 1
  • Microsoft Visual Studio 2008 Standard with Service Pack 1
  • Microsoft Dexterity 10 with Service Pack 4
  • Microsoft Dynamics GP 10 with Service Pack 4
  • Support Debugging Tool for Microsoft Dynamics GP 10
  • Visual Studio Tools with Service Pack 4 for Microsoft Dynamics GP

In addition, I needed to install Microsoft Silverlight 3, Microsoft .NET RIA Services, Microsoft Virtual Earth Control CTP, and Microsoft Dynamics GP Integration Manager 10 with Service Pack 4.

After all, I am also gearing up for the Microsoft Dynamics GP Technical Conference, so I really needed to showcase all the latest technology — well, I would have loved to have Visual Studio 2010, but Visual Studio Tools is not compatible yet — to you the developers out there.

The prep work
I started out by backing up my all files onto my home NAS and progressed from there with a checklist of the most important programs I needed after the Windows 7 installation was complete. My goal was not to have a straight upgrade from Windows Vista Service Pack 2, but rather a fresh install as mostly recommended by Microsoft anyways.

Once backups were ready and the inventory of applications was completed came the actual installation of Windows 7.

Windows 7 installation.
I popped my copy of Windows 7 Enterprise into the DVD drive and rebooted my laptop. The first surprise was the now graphical installation interface, a long shot away from the old DOS interfaces that plagued previous Windows installations. The interface was pretty intuitive to navigate. I essentially started by reformatting my existing partion. This is where the second surprised come to play. In previous installations of Windows, formatting a partition could take long minutes. Windows 7 completed the reformatting of my 76GB partition in less than 10 seconds. From there on, copying the files and extracting them onto the hard drive was pretty simple. The footprint was minimal too, occupying less than 3GB.

As a laptop user, my major concern is always drivers. Windows 7 did an excellent job recognizing all my laptop components including the wireless… this was awefully cool because, the OS could immediately access other components available online and perform some basic updates at the same time the installation was happening. The only dissapointment was my display driver. That I had to install from a pen drive that I prepared before reformatting just in case.

Once the final reboot was complete, I run the Windows Update to make sure nothing else was missing… and yes, they are already a few Windows 7 updates available. End to end, the OS took approximately 30 minutes to install, including the updates. The third surprise came then… Windows 7 was booting up three-fold faster than Windows Vista. It went from a painful 1.5-minute boot up process to less than 10 seconds. My laptop seemed to have regained some life, though I was a bit skeptic since I really hadn’t loaded anything yet.

Programs installation

SQL Server 2008 Standard with Service Pack 1
Once the Windows 7 updates were installed, I moved on to SQL Server 2008 Standard installation. SQL Server installation was pretty straight forward, however, at the beginning of the install, Windows 7 warned me that this program was written for another version of Windows and presented me with a link as to where I could find the updates for SQL Server… now that’s productivity. Windows 7 askmed me if I wanted to change the installer compatibility, and did so upon my acceptance of the message. The installation continued as usual and without any hiccups.
I then went to the SQL Server site and downloaded and installed Service Pack 1. In less than 15 minutes I was up and running with SQL Server 2008 with Service Pack 1. I restarted the laptop to test the boot up and surprisingly, nothing had changed as far as performance.

Microsoft Office 2007 Enterprise

MS Office installation went uneventful. However, when the installation was completed and I let couple minutes pass by, Windows 7 had already downloaded Office 2007 Suite Service Pack 2 and the required security updates for everything else installed at this point. I thought this would be a drag, because they were more than 35 updates between SQL Server, Office, and other driver components on my machine that needed to be applied. Wrong! When I clicked on the shut down button. Everything got installed and applied in one pass! No more multipass service pack installation bootups! Between the installation of MS Office 2007 and the service packs, I spent another 30 to 40 minutes. I also activated all the products during this time.

Microsoft Visual Studio 2008 Standard with Service Pack 1

So I then put the VS2008 DVD in the drive and began the installation. Again, nothing much to report here. Once the installation was complete, I ran Windows Update. VS2008 SP1 was next in line. That got applied successfully without any issues and the whole experience took 20 minutes tops. Other security components were installed, but this took less than 5 minutes.

Surprisingly enough at this point, my laptop’s performance seem to hold steady…

Microsoft Dexterity 10 with Service Pack 4
Dexterity took less than 2 minutes to download, and 2 minutes to install… next!

Microsoft Dynamics GP 10 with Service Pack 4
Since the introduction of Feature Pack 1 with Service Pack 2, the GP installer had already incorporated changes to deal with .NET Framework and the newer operating systems. So I decided I would start my installation with the Feature Pack 1 with Service Pack 4 installer. Everything went fine until I launched Dynamics Utilities. It complained that it could not find BCP… hmm, then I remembered Vaidy’s article on the subject when he was attempting to install on GP on Vista. It’s easy to forget that Windows 7 also implements UAC — not a sarcasm by the way. Once I ran Dynamics Utilities as administrator, between the creation of the DYNAMICS system database and the sample company, Fabrikam, some 20 minutes had passed.

I have to admit that throughout this process, my laptop “seemed to had regained its focus” on delivering what it was designed to deliver: peak performance for demanding gaming applications. This was no different for my business applications either and that made me think that Windows 7 was doing a really good job at keeping a low memory and disk overhead, giving all other applications the room needed to perform adequately.

Visual Studio Tools for Microsoft Dynamics GP
Installing VST was a bit tricky. I started with the SDK download available from PartnerSource only to find out that it was asking for an existing installation of Visual Studio 2005 or greater. Since it said “greater” I assumed VS2008 would be just fine, but the installer did not seem to recognize I had VS2008 installed. I thought for one instance that this would be the wall that would stop me in my tracks. I ran a Windows 7 compatibility analysis on the MSI and Windows 7 suggested to run it in compatibility mode “Previous Windows version”. So I did, still the same error.

It turns out VST SP2 has an additional installer that checks for the existance of VS2008 and gives you the option to install the VST Templates for VS2005 or VS2008. Phew!! Sigh of releaf! The problem was not relaed to a compatibility issue with Windows 7. I moved on to download and install VST SP4 once the initial components were installed. Because of the issues I had, I wasted precious minutes in this step, so overall it took some 45 minutes and some swearing to get through.

Support Debugging Tool
I downloaded this baby from the Support Debugging Tool download page and attempted to extract directly into the Program Files\Microsoft Dynamics\GP folder and received a priviledge error — UAC in action again. It was necessary to extract it into the My Documents folder then move to the GP folder.

I booted up GP to add the code and got prompted as such. However, after acknowledging the message I got the following error:


I have a feeling this error is Service Pack 4 related, rather than anything to do with Windows 7, but for now, SDT remains broken. I then had to rename the chunk file and move on.

Integration Manager
I began Integration Manager’s installation very aware of Vaidy’s findings with his initial installation test on Windows 7 RC, but I figured, I will once more test Windows 7 backward compatibility features. After all, this is one of the biggest selling points to customers to upgrade to Windows 7.

Everything began just fine… space requirements computed, files transferred, components registered, registry keys created. Surprisingly enough, after launching IM — expecting it to bumb out — everything was fine! I entered my registration keys and opened an integration just fine. I installed IM from the Feature Pack 1 with Service Pack 4 DVD image. Not sure if this had anything to do with my success, but there it was, up and running! The process took less than 4 minutes to complete.

All in all my laptop reinstallation took over 5 hours (including moving back files to the hard drive).

Before deciding to perform a Windows 7 upgrade, take in to consideration all the factors and applications your business is currently running. Check with each one of the manufacturers to validate compatibility. However, as an early technology adapter, I am pretty please with the results of this installation and can give Windows 7 two thumbs up!

I will certainly be performing more tests and will let you know of any issues I may encounter.

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/


Dex – Enabling long physical table names

August 26, 2009

As many of you may (or may not) know Dexterity had its origins in the days of the 8.3 file length limitation, imposed by the FAT file system found in the early versions of Windows — for more information, see the article Understanding how Microsoft Dynamics GP works with Microsoft SQL Server by David Musgrave over at Developing for Dynamics GP — This limitation reflected on the names of the physical files supported by the ISAM file servers at the time, FairCom (Ctree) and Btrieve.

The physical name constraints carried over to Microsoft SQL Server table naming convention, leaving tables with what a new bread of database administrators, systems administrators, and developers have denominated “cryptic names”. The fact is, reworking table physical names to support SQL Server would have been quite an expensive task, so the decision was made to continue with these names.

Nonetheless, Dexterity was enhanced to allow long physical table names, but this option needs to be activated prior to adding new tables to a Dexterity-based application. To enable long table names, follow these steps:

1. In Dexterity, click on the Edit menu option, then choose Options…

2. In the Options window, click on Allow Long Physical Table Names to enable the checkmark.

3. Click Ok to accept the changes. That’s it!

When the long physical table names option is not enabled, Dexterity may trick you into believing that you can enter those long names. Such physical names will then get truncated to 8 characters without any warnings.

New Microsoft Dynamics GP modules and third party applications now display long physical table names with explicit meaning, facilitating reporting from external sources. However, I still love the ‘old’ table names… they keep me gainfully busy!

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/


VBA – Creating a keyboard shortcut for a Microsoft Dynamics GP window expansion button

August 17, 2009

Well, I had been absent (more like out of ideas) from writing any new VBA articles. The truth is, they are hard to come by without giving away too many secrets. :-)

However, this one is worth giving away as I have seen many users request this feature to speed up data entry and processing. Take for example the Purchase Order Entry window. Won’t you just like the ability to press some combination of keys on your keyboard to quickly access the Vendor Detail Entry window where you can quickly change around shipping methods, or other information needed? Well this example shows just that, but can be used to add shortcuts to any other button control in any other Dynamics GP window.

The solution is simple:

1) Add a pixel size button to the window with Modifier.

2) Caption the button. Buttons can have captions preceeded with the ampersand (“&”) character, which in turn acts like a shortcut when used in combination with the Alt key on the keyboard.

As a personal choice, I captioned the button with &4, as the expansion button is Expansion Button 4.

3) In addition, we can change the button’s Visual properties to blend it in with the expansion button. I particularly prefer to stack these shortcut buttons on top of or next to the expansion button they will serve as a shortcut for.

4) The button can then be added to VBA where code can be written to force the execution the expansion button Change script. To run the Expansion Button 4 change script that will open the window, we use the Dynamics Continuum Integration library and pass-through Dexterity Sanscript.


Private Sub 4_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
Dim CompilerApp As Object
Dim CompilerMessage As String
Dim CompilerError As Integer
Dim Commands As String

' Create link without having reference marked
Set CompilerApp = CreateObject("Dynamics.Application")
Commands = ""
Commands = Commands & "run script 'Expansion Button 4' of window POP_PO_Entry of form POP_PO_Entry;"

' Execute SanScript
CompilerError = CompilerApp.ExecuteSanscript(Commands, CompilerMessage)
If CompilerError 0 Then
MsgBox CompilerMessage
End If
End Sub

The following — and much simpler! — code will also do the trick for you non-Dexterity developers:


Private Sub 4_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)
ExpansionButton4.Value = 1
End Sub

You will need to add the expansion button to VBA in addition to the pixel size button for the above code to work.

Very simple! Now when you go to the Purchase Order Entry screen, enter PO number and select a vendor, you can press Alt + 4 on the keyboard to open the associated window to the Vendor ID expansion button.

Hope you find this sample project useful.

Downloads

v10 – Sample Expansion Button shortcut package file – click here.

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/


Microsoft Dynamics GP in Russian – Microsoft Dynamics Г.П. на русском языке

July 28, 2009

For the past few months I took it up on myself to produce a translated Russian version of Dynamics GP. What began as fun little project in response to seeing a lot of GP information in Russian on Partnersource, is now showing some remarkable results. I have managed to translate 45% of the string resources and adjust the screens accordingly aided by numerous accounting software books I ordered from Moscow — and my wife who is from Moscow herself :-) — to get the proper terms and meaning in place.

Here is a sample of some of the screens (more to come),

Dynamics GP Login Window

Account Maintenance Window

Customer Maintenance Window

Unlike Chinese or Korean, the Cyrilic alphabet is not a double-byte alphabet and can easily be managed by Dexterity. However, this project was met with its own set of challenges when I started the translation process, for example, how to get Microsoft Windows to display Cyrilic characters to begin with. I sorted this out by installing Dynamics GP on a server with a default Russian locale configured. The reason this is important, as I discovered, is because ANSI characters have different values depending on the Windows locale. This way, as strings were translated in my Notepad text file, Dexterity would be able to read and display them in their native format (as long as they were not double byte characters).

For more information on the translation process I used, please take a look at Dave Musgrave‘s Translating Dexterity Applications Series of articles.

I will provide more information about the progress of this fun project and, hey!, may even consider partnering opportunities. After all, as you all know Dynamics AX is the only Microsoft product being distributed in Eastern Europe.

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/


How are Payables transactions work error messages stored?

June 24, 2009

This question came up in the Dynamics GP Partner forum a few days ago, the specifics inquiried by the consultant were as follow:

I was just looking at the PM10000 table in SQL Server Management Studio. I found a column named PMWRKMSG, with a data type of binary(4), which I cannot understand. In addition, I found entries like, 0×00019000, 0×00009000, 0×00000000 as column values. I know that they represent error messages, generated on the Batch Edit List and Posting Journals, but how can I check which message is being generated by just looking at this column? Do I need to convert this entry to some other integer and refer to some other table, which in turn would have a list of all the error messages?

Answer

The ‘PM WORK Messages’ field (PM10000.PMWRKMSG column) is a Dexterity multi-select listbox control (so are the ‘PM WORK Messages 2′ and the ‘PM Distribution Messages’ fields) which contains static texts. The only way of storing such controls (with the listbox values checked or unchecked) on SQL Server is by using a binary data type. During the posting process, a number of failed validation rules will trigger any of the 32 static text values — added by the development team — to be checked in the multi-select listbox control.

The static texts (and possible errors you may receive during posting) for the ‘PM WORK Messages’ multi-select listbox control are:


No vendor record exists for this vendor ID.
This vendor is inactive.
This transaction already has been posted.
Duplicate check numbers are not allowed.
Duplicate invoice numbers are not allowed.
No record exists for this credit card.
No unique voucher numbers are available.
This transaction has been posted and fully paid.
Distributions for this transaction contain errors.
Vendor summary records cannot be updated.
This transaction is recurring; it cannot include a payment amount.
This document should not be applied to other documents.
The total applied amount is incorrect.
Tax detail information is incorrect.
Vendor ID is on hold
Withholding Vendor ID is invalid
Applied record is on hold
Batch information is invalid
GL posting date is invalid
Fiscal period for the posting date does not exist
Fiscal period for the posting date is closed
Taxes Incorrectly Distributed
This transaction contains multicurrency error(s).
This transaction contains errors. It won't be posted.
Transaction Analysis information for this transaction is incorrect or missing.
Transaction contains intercompany distributions; mark as an IC transaction.
Intercompany Processing is not registered;cannot post intercompany transactions
The currency must be either the functional currency,
The currency must be the same as the currency assigned to the checkbook
the Euro currency,
an enabled denomination currency,
or the same as the currency assigned to the checkbook

Assuming the values follow a binary storage pattern, 0×00009000, can be converted to its decimal equivalent of 36,864. In turn, this number can be represented as 2^15 + 2^12. If is the case, the error messages displayed on the batch edit list are: “Withholding Vendor ID is invalid” and “The total applied amount is incorrect”. In the case of 0×00019000, this is 2^16 + 2^15 + 2^12, this would result in the messages “Applied Record is on hold”, “Withholding Vendor ID is invalid” and “The total applied amount is incorrect”.

Of course, these errors can only be cleared via the interface, since resetting the value in SQL Server would have no direct effect on the validation rules applied by the posting process. A transaction will not move to the PM Transaction Open table (PM20000) if all the validation rules are not cleared, which in turn would render a value of 0×00000000 in the column.

The ‘PM WORK Messages 2′ multi-select listbox field stores the following static text values:


You cannot post to a tax date within a closed tax period.
You cannot post to a tax period that has not been set up.
The vendor's remit to address bank format is missing or inactive.
The bank format for the vendor and the checkbook must be the same country.
The bank format for the vendor and the checkbook must be different countries.
The bank format assigned to the checkbook is missing.
This check amount exceeds the maximum check amount for the checkbook.
Remit-To address doesn't exist; please enter a different address.

The above errors are mostly used during the validation of tax computations and vendors setup as EFT vendors.

The ‘PM Distribution Messages’ multi-select listbox field stores the following static text values:


The accounts payable distribution(s) does not equal the actual amount.
The purchases distribution(s) does not equal the actual amount.
The discount available distribution(s) does not equal the actual amount.
The trade discount distribution(s) does not equal the actual amount.
The discount taken distribution(s) does not equal the actual amount.
The misc distribution(s) does not equal the actual amount.
The freight distribution(s) does not equal the actual amount.
The tax distribution(s) does not equal the actual amount.
The cash distribution(s) does not equal the actual amount.
The write off distribution(s) does not equal the actual amount.
The other distribution(s) does not equal the actual amount.
The GST distribution(s) does not equal the actual amount.
The withholding distribution(s) does not equal the actual amount.
The debit distributions do not equal the credit distributions.
No account has been specified for one or more distributions.
The Realized Gain distribution(s) does not equal the actual amount.
The Realized Loss distribution(s) does not equal the actual amount.
The Round distribution(s) does not equal the actual amount.

Hope this helps in troubleshooting and understanding how Dynamics GP processes and manages errors when executing a Payables transaction posting validation.

Until next post!

MG.-
Mariano Gomez, MIS, MVP, MCP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/


Retrieving Windows Registry key values with Microsoft Dexterity

June 12, 2009

Every so often you get these development requests that seem to push Dexterity to its limits. One of such requests is being able to read a Windows Registry key value using nothing more than SanScript.

The following example will show how to use the Microsoft Windows Management Instrumentation (WMI) Scripting library, ADVAPI32.DLL to retrieve a Windows Registry key value by examining how to retrieve the default Internet browser software being used.

The code will use the RegOpenKeyA and RegQueryValueExA DLL functions to a) return a handle for the registry path where we can found the key, b) then retrieve the actual key value. In order to access external DLL functions, it is necessary to create Dexterity prototype global procedures for the external DLL functions.

RegOpenKeyA@ADVAPI.DLL


{ prototype procedure RegOpenKeyA@ADVAPI.DLL }
out long return_value; {function returns ERROR_SUCCESS }
in long hKey; {Handle of parent key to open the new key under}
in string lpcstr; {Name of the key under hkey to open }
inout long phkey; {Destination for the resulting Handle }

RegQueryValueExA@ADVAPI32.DLL


{ prototype procedure RegQueryValueExA@ADVAPI32.DLL }
out long return_value; {function returns ERROR_SUCCESS }
in long hKey; {handle of the key to query }
in string sName; {Name of value under hkey to query }
in long lReserved; {Reserved, must be null }
inout long lType; {Destination for the value type, or NULL if not}
{required. }
inout string sKeyValue; {Destination for the values contents, or NULL }
{if not required. }
inout long lResultLen; {Size of sKeyValue, updated with the number of }
{bytes returned. }

Now that we have the prototype functions, we can proceed to use the Constant Definition window in Dexterity to define values for each Registry hive.

Registry Hive Constants


Constant Name Constant Value
HKEY_CLASSES_ROOT 2147483648
HKEY_CURRENT_USER 2147483649
HKEY_LOCAL_MACHINE 2147483650
HKEY_USERS 2147483651
HKEY_PERFORMANCE_DATA 2147483652
HKEY_CURRENT_CONFIG 2147483653

NOTE: These constants are usually known by their hexadecimal values, but Dexterity does treats hexadecimal constants as strings, hence the decimal notation used.

Once the prototype functions have been defined, we can wrap these in an API that isolates the developer from dealing with the innerworks of the calls. We will define to global functions as follow:

RegKeyExists


{ global function RegKeyExists }
function returns long phkey;

in long hkey;
in string lpcstr;

local long return_value;

try
extern 'RegOpenKeyA@ADVAPI32.dll'
, return_value
, hkey
, lpcstr
, phkey;
catch[EXCEPTION_CLASS_OBJECT_EXCEPTION]
error "Error calling RegOpenKeyA@ADVAPI32.DLL. Could not locate DLL pointer.";
else
throw;
end try;

RegKeyExists accepts the registry hive parameter (hkey) and the registry path and returns a handler if the path is valid (phkey).

RegGetKeyValue


{ global function RegGetKeyValue }
function returns string key_value;
in long hKey;

local long return_value, lValueType, lValueLength;
local string sKeyValue;

set lValueLength to 255;

try
extern 'RegQueryValueExA@ADVAPI32.DLL'
, return_value
, hKey
, ""
, 0
, lValueType
, sKeyValue
, lValueLength;
catch[EXCEPTION_CLASS_OBJECT_EXCEPTION]
error "Error calling RegQueryValueExA@ADVAPI32.DLL. Could not locate DLL pointer.";
else
throw;
end try;

if return_value = OKAY then
key_value = sKeyValue;
else
key_value = "KEY_ERROR";
end if;

RegGetKeyValue in turn will take the handler (returned by RegKeyExists) and attempt to retrieve a value for the Default entry of the path previously given. If the function succeeds, it will return a string with the actual value, else the user will get a KEY_ERROR message.

Making it all work together..

For this project, I have created the following form:

The form contains 4 local variables:

‘(L) RegistryHive’: is a drop-down list with the following string values corresponding to each registry hive, as follows: HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA, and HKEY_CURRENT_CONFIG.

‘(L) RegistryPath’: is a string of 255 characters in length.

‘(L) RegistryKey’: is a string of 50 characters in length, not used in this project. I will leave this for a future post.

‘(L) RegKeyValue’: is a string of 255 characters in length. Set the property to Editable to False.

Now that you have the strings and drop-down list, drag the ‘OK Button’ push button control to finish — I am working in the Dynamics dictionary, DYNAMICS.DIC.

The actual production form will look like this:

We can now add the following Sanscript code to the OK Button change script:

syGetRegistryKey OK Button K_CHG


local long hKey; { [In] Handle to an open key. }
local long lHive;

local long return_value, nSubkeys, nSubkeyMaxSize,nMaxChars, nValues, lValueName, lValueData, lClassLen;
local reference ft;
local string lClass;

{ check for the last backslash character on the path string }
if substring('(L) RegistryPath', length('(L) RegistryPath'), 1) CH_BACKSLASH then
'(L) RegistryPath' = '(L) RegistryPath' + CH_BACKSLASH;
end if;

{ check the hive selected from the DDL and assign the proper constant }
case '(L) RegistryHive'
in [1] lHive = HKEY_CLASSES_ROOT;
in [2] lHive = HKEY_CURRENT_USER;
in [3] lHive = HKEY_LOCAL_MACHINE;
in [4] lHive = HKEY_USERS;
in [5] lHive = HKEY_PERFORMANCE_DATA;
in [6] lHive = HKEY_CURRENT_CONFIG;
end case;

{ establish if the key entered is valid within the hive }
hKey = RegKeyExists(lHive, '(L) RegistryPath');

{ RegKeyExists will return 0 if the path does not exist within the hive,
else it will return the handle value for the key
}

lClass = "";
lClassLen = 0;

if hKey 0 then
{ Get the key value; will append the key to the path to make it whole }
'(L) RegKeyValue' = trim(RegGetKeyValue(hKey));
else
warning "Invalid registry key entered";
end if;

You can compile and run the code in test mode and use the Developer Assistant form to open the newly created form. For example, let’s check the registry for the default Internet browser running:

I will be taking a shot a two other functions in the Microsoft WMI Scripting library in a futute installment. Hope you enjoy this article and can’t wait to hear your comments.

Acknowledgements

A big thank you to Jon Eastman for his insight on the ADVAPI32.DLL. He gave me the idea for this post… that’s what it’s all about!

Until next post!

MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com


Follow

Get every new post delivered to your Inbox.

Join 25 other followers