开发者

Reading the registry of a windows computer from a web app (silverlight? java?)

开发者 https://www.devze.com 2022-12-20 00:01 出处:网络
Is there a way to read the windows registry from a开发者_Go百科 web based application with no user interaction? I\'m open to any technology suggestion.This can be done in java:

Is there a way to read the windows registry from a开发者_Go百科 web based application with no user interaction? I'm open to any technology suggestion.


This can be done in java:

public class RegistryRead {
 public static void main(String[] args) {
   RegistryRead demo = new RegistryRead();
   demo.doit();
   // IO.PressAnyKey();       
   }

 public void doit() {
   displayUserName();
   displayODBCDSN();
   }

 public void displayUserName(){
   com.ms.wfc.app.RegistryKey regKey;
   String userName;
   regKey =
     com.ms.wfc.app.Registry.LOCAL_MACHINE.getSubKey
       ("Network\\Logon");
   if (regKey == null) {
     userName = "Unable to get username from Registry!";
     }
   else {
     userName = (String) regKey.getValue("username");
     }
   System.out.println("Username : " + userName);
   }

 public void displayODBCDSN() {
   com.ms.wfc.app.RegistryKey regKey;
   regKey =
     com.ms.wfc.app.Registry.CURRENT_USER.getSubKey
       ("Software\\ODBC\\ODBC.INI\\ODBC Data Sources");
   if (regKey == null) {
     System.out.println("Unable to get ODBC DSN Registry!");
     }
   else {  
     String dsn [] = regKey.getValueNames();
     System.out.println("ODBC DSN defined : ");
     for(int i = 0;  i < dsn.length; i++) { 
       System.out.println(dsn[i]);
       }
     }
 }
}


Nope. Web techs such as silverlight are designed to run sandboxed by default. There are certain actions that are allowed/enabled by silverlight that break that convention but they all require explicit confirmation by the user.


I'm afraid that the short response, as already stated, to your question is NO, you can't access the registry from client.

Maybe you can resort to an activex (bounding your application to Microsoft browsers)

Maybe, if your goal is just to implement some sort of user/license verification (I interpret in this way your response to my comment), you may find useful the webstorage / client side storage alternatives.

As I know there are different implementation, technologies, you can leverage on.

A starting point for your investigations can be

http://wonko.com/post/search-pad-browser-storage


.NET offers ways of doing this, http://msdn.microsoft.com/en-us/library/85t3c3hf.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消