What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » does a registry string exhist

does a registry string exhist
Author: Message:
JonnyT
Junior Member
**


Posts: 28
Joined: Jun 2006
O.P. does a registry string exhist
i know the registry options are limited but is tere away to find out if a certain string exhists? Im doing this becuase the script chucks out an error if i try to read from a string tht doesnt exhist.

Thanks jon
06-29-2006 07:11 PM
Profile E-Mail PM Find Quote Report
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
RE: does a registry string exhist
I use this to check if a key exists.

It returns true if it does, and false if it doesn't exist.

Btw, it doesn't check for a value, just a key. But you can modify it. Instead of "return true", make it "return tmp" and check the returned value with whatever you want.

code:
function isreg(path) {
var reg, tmp;
  try {
  reg = new ActiveXObject("WScript.Shell");
  tmp = reg.RegRead(RegUserPath + path);
   if(tmp != "") return true;
  } catch(e) {
  return false;
  }
}


This is just a workaround, not a real solution, but it works and prevents the script from returning an error.

You can read more of try...catch...finally in the MSDN library.



quote:
Originally posted by RaceProUK
quote:
Originally posted by Leonardo
if(tmp != "") return true;
:dodgy:
code:
return tmp != "";

Oh, genious. :rolleyes:

Seriously people, is there a difference? Except from saving 0.00001 second and a couple of bytes, is there really a difference? No? Then, let it go. :dodgy:

This post was edited on 06-29-2006 at 09:48 PM by L. Coyote.

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

06-29-2006 07:18 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: does a registry string exhist
http://mattyg.ca/geshi/registry.php

My registry module has KeyValueExist among other functions

CreateKey
DeleteKey
DeleteKeyValue
KeyExist
SetDWordValue
SetStringValue
GetDWordValue
GetStringValue

Will be including an EnumRegistryKeys and possibly Get/Set Binary keys.
06-29-2006 07:31 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: does a registry string exhist
quote:
Originally posted by Leonardo
if(tmp != "") return true;
:dodgy:
code:
return tmp != "";
[Image: spartaafk.png]
06-29-2006 09:36 PM
Profile PM Web Find Quote Report
JonnyT
Junior Member
**


Posts: 28
Joined: Jun 2006
O.P. RE: does a registry string exhist
thanks matty your scripts worked great :D
06-29-2006 09:43 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: does a registry string exhist
quote:
Originally posted by Leonardo
Seriously people, is there a difference? Except from saving 0.00001 second and a couple of bytes, is there really a difference? No? Then, let it go. :dodgy:
yes there is a difference. and "return tmp != "";" is prefereable.

Moreover, checking if tmp is empty isn't a good thing todo as keys can also be empty (yet existing). That line should actually just be "return true".

This post was edited on 06-29-2006 at 10:41 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
06-29-2006 10:38 PM
Profile PM Find Quote Report
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
RE: does a registry string exhist
I already said in that post of mine, that if the person wants to directly return the string, then they simply change that part.

As for the empty string, true. But that function is specifically done for that purpose. I just kindly gave it out as an example.

:^) This all makes me think I shouldn't be that kind after all, seeing everytime I do someone complains about my coding, or simply steals it.

* L. Coyote learns from mistakes. :D

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

06-29-2006 10:57 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: does a registry string exhist
quote:
Originally posted by Leonardo
:^) This all makes me think I shouldn't be that kind after all, seeing everytime I do someone complains about my coding, or simply steals it.
Get over it already! I'm actually slightly offended that you think I complain about other people's code: I don't, I suggest improvements. And I expect people to suggest improvements to my code.
[Image: spartaafk.png]
06-30-2006 11:48 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On