日期:2014-05-18  浏览次数:20758 次

新手求助:C#注册表问题(在线等)
想在asp页面显示当前用户的分辨率.
public   void   MyDisplay()
                {
                        RegistryKey   Key1   =   Registry.CurrentConfig.OpenSubKey( "System\\CurrentControlSet\\Control\\Video ",   true);
                       
                        //RegistryKey   Key2   =   Key1.OpenSubKey( "{99903A14-FFEB-4220-9BC0-A6928EA09220} ");-----请问这个子键每台电脑都不是一样的(好象是随机),怎么样才能到下一个子健0000呢?
                      //   RegistryKey   Key2   =   Key1.OpenSubKey( "0000 ");
                        string   XResolution   =   Convert.ToString(Key1.GetValue( "DefaultSettings.XResolution "));
                        string   YResolution   =   Convert.ToString(Key1.GetValue( "DefaultSettings.YResolution "));
                        Response.Write( "您目前的分辨率是:【 "   +   XResolution   +   "× "   +   YResolution   +   "】!   ");
                        Key1.Close();                        
                }
我用上面的方法能成功显示,但关键是别人的电脑不会也是{99903A14-FFEB-4220-9BC0-A6928EA09220}吧.???

------解决方案--------------------
显示客户端的分辨率?
你没有权限读取注册表的。一般是javascript即可
---------------------------------------
正解
------解决方案--------------------
可以使用这种方法

http://dotnet.aspx.cc/article/hlfq4zoy-n3go-4r7y-wy5r-xzzn2jy5j8hz/read.aspx
http://dotnet.aspx.cc/Exam/ClientPeek.aspx
------解决方案--------------------
就是通过脚本,将分辨率得到放在隐藏的表单域里面,然后传递到服务器
scriptString += "document.all.browserpeek.WidthPixel.value=window.screen.width;\r\n ";
scriptString += "document.all.browserpeek.HeightPixel.value=window.screen.height;\r\n ";