SW API and the Registry
SW API and the Registry
(OP)
Howdy all,
I just need to ask this question before I waste any time trying to do something. I know there are some limitations to the SW API, I'm not sure what they all are.
Is the Windows Registry open to the SW API? Can I use the Windows Registry in a SW macro?
Thanks
I just need to ask this question before I waste any time trying to do something. I know there are some limitations to the SW API, I'm not sure what they all are.
Is the Windows Registry open to the SW API? Can I use the Windows Registry in a SW macro?
Thanks
Tobin Sparks
www.nov.com






RE: SW API and the Registry
Registry Utilities for VB Projects
<http://www.esoxrepublic.com/devtools/>
This is a module to add to VB6 or VBA project with functions to get access to registry.
http://www.EsoxRepublic.com-SolidWorks API VB programming help
RE: SW API and the Registry
Excellent information! Thank you so much.
Tobin Sparks
www.nov.com
RE: SW API and the Registry
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: SW API and the Registry
Man - I can't hide anything. How am I going to do any magic
Tobin Sparks
www.nov.com
RE: SW API and the Registry
Thank you for your "Registry Utilities for VB Projects". That must have taken some time and effort to complete. I used it with a SW Macro and it seems to work just fine.
However, I did have to make a little adjustment for my particular application. Since this is way over my head I'm not sure if it's a correction or not. I ran into problems when I tried to save just one character in the Registry. I've not read of such a limitation when saving to the Registry. Also I couldn't consistently save a number that started with a decimal point and I couldn't figure out why. I'm not sure if that is a limitation of the Registry.
Attached is a .bmp file that shows the changes I made for my application.
Thanks again for this effort, I'm sure I'll use it again
Tobin Sparks
www.nov.com
RE: SW API and the Registry
-handleman, CSWP (The new, easy test)
RE: SW API and the Registry
Thanks for looking at this. I totally agree with you, it doesn't make sense. For some reason an exception was thrown at this point when I tried to save just one character. I was not trying to save hex or octal data. The change stops the exception and that makes me happy.
Thanks
Tobin Sparks
www.nov.com
RE: SW API and the Registry
(Right(CStr(varRegData), Len(Cstr(varRegData)) - <b>2</b>))
if varRegData is only one character, then Len(Cstr(varRegData)) - <b>2</b> equals -1. A negative number is an invalid argument for the "Right" function, so you get an error.
Rather than making the change you made (which renders that entire If statement meaningless and reduces future code functionality/modularity), I would suggest a nested If be added to each instance of that type of code block, for example:
CODE
[the original "If" statement]
End If
If you don't do this, I would suggest removing that line entirely rather than leaving it in with the change you made.
-handleman, CSWP (The new, easy test)
RE: SW API and the Registry
WOW - okay I'll look into it and let you know what we decide.
Thanks so much for looking at this
Tobin Sparks
www.nov.com
RE: SW API and the Registry
Thank you for your involvement in this issue. You are absolutely right of course. I looked at it too quickly and thought it wouldn't matter. Thanks for getting me to do the right thing :-) . Attached is a .bmp of the additions I made. The original functionality is still intact, although it still makes no sense.
I would think TheTick would be interested in this. Someone with experience understanding this module might want to look this over. I tried to contact Kenneth Ives who claims responsibility for this code but the email was undeliverable.
Thanks Again
Tobin Sparks
www.nov.com
RE: SW API and the Registry
-handleman, CSWP (The new, easy test)
RE: SW API and the Registry
Okay - are you messing with me now
The reason I did it this way is because "Case ForceDataType" is the only one of the Cases in the Sub that is declared. The other three are not functioning. This is what the Sub declaration looks like: <Public Sub regCreate_Key_Value(ByVal lngRootKey As Long, ByVal strRegKeyPath As String, _
ByVal strRegSubKey As String, varRegData As Variant, Optional ForceDataType As regValueType_e = regDoNotForce)>
Nothing in the rest of the code declares the other three Cases. Therefore - regDoNotForce is the only one of those Cases set up in the whole code. Doesn't make sense to me but if that's the situation I can live with it.
So - attached is what I'm thinking you're trying to get me to do. I can see the logic behind this. I hope I got it right this time.
Thanks
Tobin Sparks
www.nov.com
RE: SW API and the Registry
RE: SW API and the Registry
OOHH - that makes sense. I thought it might be something like that. So - are you going to weigh-in on this issue?
Thanks
Tobin Sparks
www.nov.com
RE: SW API and the Registry
RE: SW API and the Registry
WOW - that's fantastic! Congratulations! I would've never guessed you were a female
Enjoy
Tobin Sparks
www.nov.com
RE: SW API and the Registry
In the remarks, you will see that much of the code came from codetoad.com. I did add a few functions, but what you modified is one of the original codetoad functions.
I never had a problem like you describe. The reason is probably because I am always specific with my data types, and the problem code is for untyped data. I recommend you do the same. Get familiar w/ registry data types and be type-specific when writing to registry.
There may be a few other glitches, as well. I know that enumerating keys does not always catch everything. That is a Windows API issue, out of my control.
The reg utilities are offered on an as-is use-at-your-own-risk basis. This is in part because I have not fully tested the entire module. Also because registry is a sensitive thing. I want programmers to be able to see what they are getting into, code-wise.
RE: SW API and the Registry
Thanks for your input. I really appreciate it.
I guess I'm learning this backwards
Yes I understand reg utilities is an as-is use-at-your-own-risk module. I'm actually glad it is. It's free! Just thought you would like to be aware of the discovery. I sometimes seem to have a Knack for finding little glitches
Thanks for your input, you've been very helpful in many ways
Tobin Sparks
www.nov.com