Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-17-2007, 03:23 PM
Junior Member
 
Join Date: Apr 2007
Posts: 22
Default Registry Problem

I am using the following code to retrieve the current values in the registry...

Code:
r = new RegKey("HKLM\\Software\\ILSP\\LAMDA");
value = r.getValues();
if the values that I get are the one I want the applications executes, otherwise it exits. The whole thing is working fine...

But when I work with a user in Windows XP that hasn't got administration privileges, the application cannot access the values from the registry.

So I want a way to ensure that the function

Code:
new RegKey("HKLM\\Software\\ILSP\\LAMDA");
will access the registry without WRITE privileges, only READ so it can run at any user account under windows XP.
Reply With Quote
  #2 (permalink)  
Old 10-18-2007, 06:26 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Registry Problem

Yes, you can use the second parameter to indicate the access rights

Code:
r = new RegKey("HKLM\\Software\\ILSP\\LAMDA", 131097/*KEY_READ*/);
Reply With Quote
  #3 (permalink)  
Old 10-19-2007, 01:45 PM
Junior Member
 
Join Date: Apr 2007
Posts: 22
Default Re: Registry Problem

Thanx for the immediate answer...but it doesn't work. It still doesn't read the registry without administrative privileges.

The Code I am using, retrieves the value of INSTALLID variable and if it's length is equal to 4 it approves the user.

Code:
	
r = new RegKey("HKLM\\Software\\ILSP\\LAMDA", 131097/*KEY_READ*/);
values = r.getValues();

for (i = 0; i < values.length; i++)
{
	if (values[i].name == "INSTALLID") 
	{
		installID = String(values[i].data);
		if (installID.length == 4) {
		  _root.$APP.installID = installID;
		}
	}
}
Reply With Quote
  #4 (permalink)  
Old 10-21-2007, 06:40 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Registry Problem

When the code runs without administrative privileges, does r return null? We have tested the code with a guest account and found that it works well.
Reply With Quote
  #5 (permalink)  
Old 10-22-2007, 06:49 AM
Junior Member
 
Join Date: Apr 2007
Posts: 22
Default Re: Registry Problem

I created a simple .exe file, to show you the problem.

In the zip file you will find all the source files, plus the REGISTRY entry (Lamda.reg). Before you test the code, execute "Lamda.reg" file.

The code is the following:
Code:
import SWFKit.*;
r = new RegKey("HKLM\\Software\\ILSP\\LAMDA", 131097/*KEY_READ*/);

values = r.getValues();

_txt.text += "\n r = new RegKey('HKLM\\Software\\ILSP\\LAMDA', 131097/*KEY_READ*/); returns...\n";
_txt.text += r;
_txt.text += "\n r.getValues(); returns...\n";
_txt.text += values[1].data;
If you run the ".exe" file in a user with administrative privileges. r returns [Object object] and values[1].data = 9999. (according to the values set by the Lamda.reg file).

BUT if you run the same "exe" in a user without administrative privileges, r still returns [Object object] (it always does, even if you compile it in flash) but values doesn't return "undefined".

I think that the problem is in this line -> values = r.getValues();
It doesn't return anything...

Please give me a solution ASAP, I am in a tight schedule.

If no solution can be found in this problem...I would like to know some way of detecting whether the user has administrative privileges or not, and if he doesn't the application will not execute.
Reply With Quote
  #6 (permalink)  
Old 10-24-2007, 12:12 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Registry Problem

The wrapper class for the RegKey object (RegKey.as) does not pass the second parameter to swfkit, so it does not work although you have specified the "key_read" access flag. To solve the problem, please write a ffish script function
Code:
function readValue() {
  r = new RegKey("HKLM\\Software\\ILSP\\LAMDA", 131097/*KEY_READ*/);
  values = r.getValues();

  for (i = 0; i < values.length; i++)
  {
	if (values[i].name == "INSTALLID") 
	{
		installID = String(values[i].data);
		if (installID.length == 4) {
		  return installID;
		}
	}
  }

  return "";
}
and then call it in actionscript
Code:
_root.$APP.installID = ExternalInterface.call("readValue");
Reply With Quote
  #7 (permalink)  
Old 10-25-2007, 01:35 PM
Junior Member
 
Join Date: Apr 2007
Posts: 22
Default Re: Registry Problem

I am having trouble on executing the function from actionscript.

I copy-pasted the function INSIDE the Initialize script (between getAdditionalFile() and after return true

and I tried calling the function from actionscript with the ExternalInterface.call("readValue"), but I am getting "undefined" all the time.

Probably I am setting or calling the function correctly.

The project is in AS2 not AS3.

Thanx and sorry for the trouble.
Reply With Quote
  #8 (permalink)  
Old 10-29-2007, 07:53 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Registry Problem

It should work in either as2 or as3.

Please make sure that the function is in the "initialize" script before "return true;" And in actionscript, maybe you need to add "import flash.external.*". If you still cannot make it work, please feel free to let us know. We will send a sample to you.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:34 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.