March 29, 2024, 03:05:30 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Marking a function as a success or a failure

Started by Andy, August 09, 2017, 03:08:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

I've managed to successfully copy a Major registry key - with the exception of a few open keys.

The question is should I mark this down as a success or a failure?

I could return 3 possible states:

1. Success
2. Success with some Errors
3. Failure.

What's your thoughts on this please?
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

The way I look at it is,
Did the function successfully complete its intended purpose, yes or no?
Your title for this post says it all "success or a failure".

Is the purpose of the function to copy the key and ALL of it's sub keys or
is its purpose to copy the key and all of the sub keys that it can?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Andy

August 09, 2017, 10:31:06 PM #2 Last Edit: August 09, 2017, 10:40:50 PM by Andy
A good question Larry,

The intention of the function is to copy a sub key of HKEY_CURRENT_USER\Software.

For that purpose it is successful - with the exception of HKEY_CURRENT_USER\Software\Microsoft.

I was just seeing if the function could copy the whole of the \Software key out of curiosity as it contains many (thousands) sub keys and values.

When trying to copy HKEY_CURRENT_USER\Software to say HKEY_CURRENT_USER\Software2 the program would at some point crash out.  I found the first key that made it crash - it was because the sub key had only READ access - not full.

So for the Registry lib file i'm writing I've changed the open key command from:

   if RegOpenKeyExA(GetRoot(Key),ky,0,@KEY_ALL_ACCESS,ret) = 0

   to

   if RegOpenKeyExA(GetRoot(Key),ky,0,@KEY_READ,ret) = 0

@KEY_ALL_ACCESS will cause the RegOpenKeyExA to fail on read only keys, and after all if we are just copying a key we only need to read that key not have full access to it.

RegCopyKey function will copy all sub keys and values, the values it can copy are:

Strings
Expandable strings
Multi strings
Dwords
Qwords
Binary
Null entries (REG_NONE).

Now I've jumped that one, I'm writing a RegExport function to export keys and values to a .reg file
this new function will export all the above values with the exception of Qwords as these are UINT64 decimal values and at the moment I cannot convert them to hex.

Andy.


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.