Net1.1没有专门封装好的WIN32管理类(2.0就方便多了),分享一下目录共享及权限的方法(网上找了许多都是文不对题的)
权限定义:
[Flags]
public enum AccessPrivileges : uint{
FILE_READ_DATA = 0x00000001,
FILE_WRITE_DATA = 0x00000002,
FILE_APPEND_DATA = 0x00000004,
FILE_READ_EA = 0x00000008,
FILE_WRITE_EA = 0x00000010,
FILE_EXECUTE = 0x00000020,
FILE_DELETE_CHILD = 0x00000040,
FILE_READ_ATTRIBUTES = 0x00000080,
FILE_WRITE_ATTRIBUTES = 0x00000100,
DELETE = 0x00010000,
READ_CONTROL = 0x00020000,
WRITE_DAC = 0x00040000,
WRITE_OWNER = 0x00080000,
SYNCHRONIZE = 0x00100000,
ACCESS_SYSTEM_SECURITY = 0x01000000,
MAXIMUM_ALLOWED = 0x02000000,
GENERIC_ALL = 0x10000000,
GENERIC_EXECUTE= 0x20000000,
GENERIC_WRITE = 0x40000000,
GENERIC_READ = 0x80000000
}
[Flags]
enum AceFlags : uint{
NonInheritAce = 0,
ObjectInheritAce = 1,
ContainerInheritAce = 2,
NoPropagateInheritAce = 4,
InheritOnlyAce = 8,
InheritedAce = 16
}
[Flags]
enum AceType : uint{
AccessAllowed = 0,
AccessDenied = 1,
Audit = 2
}
流程:
//设置Everyone用户,可以选择其他用户或新建用户
ManagementClass trustee = new ManagementClass("Win32_Trustee");
trustee.Properties["Name"].Value = "Everyone";
trustee.Properties["Domain"].Value = null;
trustee.Properties["SID"].Value = new byte[]{1,1,0,0,0,0,0,1,0,0,0,0};
//设置只读/运行权限
ManagementClass ace = new ManagementClass("Win32_ACE");
ace.Properties["AccessMask"].Value = AccessPrivileges.GENERIC_READ
| AccessPrivileges.FILE_READ_DATA | AccessPrivileges.FILE_READ_ATTRIBUTES | AccessPrivileges.FILE_READ_EA
| AccessPrivileges.READ_CONTROL | AccessPrivileges.FILE_EXECUTE;
ace.Properties["AceFlags"].Value = 3;//AceFlags.ObjectInheritAce | AceFlags.ContainerInheritAce ;
ace.Properties["AceType"].Value = 0;//AceType.AccessAllowed;
ace.Properties["Trustee"].Value = trustee;
//修改ACL设置
ManagementObject secDescriptor = new ManagementClass("Win32_SecurityDescriptor");
secDescriptor["ControlFlags"] = 4;
secDescriptor["DACL"] = new ManagementObject[] { ace };
//设置添加共享
ManagementClass mc = new ManagementClass("win32_share");
ManagementBaseObject inParams = mc.GetMethodParameters("Create");
inParams["Path"] = "f:\\dannyr";
inParams["Name"] = "share of dannyr";
inParams["Type"] = 0x0;
inParams["MaximumAllowed"] = null; //=null 则用户数连接无限制
inParams["Description"] = null;
inParams["Password"] = null;
inParams["Access"] = secDescriptor; //=null 则使Everyone拥有完全控制权限
ManagementBaseObject outParams = mc.InvokeMethod("Create", inParams, null);
uint returnValue = (uint)outParams.Properties["ReturnValue"].Value;
string ErrorMessage = null;
switch (returnValue)
{
case 0: //Success
break;
case 2: //Access denied
ErrorMessage = "无权访问";
break;
case 8: //Unknown failure
ErrorMessage = "未知错误";
break;
case 9: //Invalid name
ErrorMessage = "非法的共享名";
break;
case 10: //Invalid level
ErrorMessage = "非法的层次";
break;
case 21: //Invalid parameter
ErrorMessage = "非法的参数";
break;
case 22: //Duplicate share
ErrorMessage = "重复共享";
break;
case 23: //Redirected path
ErrorMessage = "重定向路径";
break;
case 24: //Unknown device or directory
ErrorMessage = "未知的目录";
break;
case 25: //Net name not found
ErrorMessage = "网络名不存在";
break;
default:
break;
}
Access数据库对于文本和备注类型的数据类型定义(DATA_TYPE)都是为130,无法直接区分,找了N多网页,包括MSDN都没有描述有关COLUMN_FLAGS的说明,还是自己分析一下:
COLUMN_FLAGS为64位(8字节)的十六进制的值,组合了数据类型和必填字段等信息
其中最后2个字节有效,最后一个字节一直为0x0A,有变化的是最后第二个字节,即:
对于文本类型的为0x00;备注类型为0x80;
对于非必填字段为0x40;必填字段为0x60
组合后:
文本必填: 0x6A
文本非必填:0x4A
备注必填: 0xEA
备注非必填:0xCA
最后可以得到COLUMN_FLAGS右移7位后可以区分文本类型和备注类型
DataTable dt = m_OLEDBCon.GetOleDbSchemaTable(
OleDbSchemaGuid.Columns,
new object[] {null, null, "表名称", null});
DataRow[] drs = dt.Select("COLUMN_NAME='字段名称'");
if(drs.Length > 0 && Convert.ToInt32(drs[0]["DATA_TYPE"]) == 130) {
//文本类型
if ( (Convert.ToInt64(drs[0]["COLUMN_FLAGS"]) >> 7) == 1){
//=1为备注字段
}else{
//=0为文本字段
}
}
摘要: As is known,in many advanced programming languages(esp. object oriented ones) like c/c++,c#,Java,etc., the function is only one of the programming syntax constructs,unlike that in some pure interprete...
阅读全文
var firefox = document.getElementById && !document.all;
IE浏览器和FireFox浏览器都有getElementById方法,而FireFox没有document.all方法,因此当上面firefox变量为false说明为IE浏览器。
下载:
http://www.adobe.com/cfusion/entitlement/index.cfm?e=labs_spry
Changes for Spry PreRelease 1.4 - 2006/12/14
- Data
- Added function Spry.Utils.serializeObject() for serializing a JS Object into JSON format.
- Added Spry.XML.nodeToObject() and Spry.XML.documentToObject() utility methods which allow developers to access XML data as JS properties on an object in a manner which is similar to E4X.
- Added Spry.Utils.updateContent() for dynamically loading an HTML fragment into an element.
- Added Spry.Utils.setInnerHTML() for setting the innerHTML of an element and executing any scripts within the content string. This method is now used by Spry regions when regenerating their content.
- Added support for mapping a region state name to another state name. This can be useful for overriding the built-in states, like "ready", "loading", and "error", so that they use markup from a custom state when they fire.
- Added support for more attributes:
- spry:even - Conditionally adds the user specified CSS class name to an element based on the current row number used at the time that element was re-generated.
- spry:odd - Conditionally adds the user specified CSS class name to an element based on the current row number used at the time that element was re-generated.
- spry:setrow - Attaches a non-destructive onclick handler that sets the current row by row ID.
- spry:setrownumber - Attaches a non-destructive onclick handler that sets the current row by row number.
- spry:sort - Attaches a non-destructive onclick handler that sorts a specific data set based on columns specified by the user.
- spry:readystate - Maps the "ready" state name to the name specified in its value.
- spry:errorstate - Maps the "error" state name to the name specified in its value.
- spry:loadingstate - Maps the "loading" state name to the name specified in its value.
- Added code to report and error when nested regions and detail regions are detected.
- Added new methods to the DataSet API:
- getRowCount()
- getRowByID()
- getRowByRowNumber()
- findRowsWithColumnValues()
- Effects
- Minor updates of documentation (effects_api and effects_coding, especially of the allowed elements to which the effects can be applied to).
- Fixed bugs:
- GrowShrink effect: if border is set, width&height style doesn't get reset to the original value after you toggled the target element
- GrowShrink effect: text size inside the target element is alternated after the effect has been finished
- Slide and Blind effect: Scrollbar disappears if overflow:scroll is set and you toggle the element
- GrowShrink effect: nested image elements doesn't grow if you grow the target element
- Slide effect: Text inside sliding element doesn't appear once you toggle the effect (IE 7 only)
- Shake effect: doesn't work perperly in Opera 9.0
- AppearFade effect: not working for content of a <div> inside a <td> (IE only)
- new feature:
- GrowShrink effect: added options 'referHeight' and 'growCenter'
- IE 7 related fixes also take effect on Windows Vista (not only on XP)
- new feature:
- Slide effect: added option 'horizontal' to allow horizontal sliding
- Slightly updated documentation to reflect new slide option
- Simplified cluster construction: cluster now is an effect, too, which accepts setup and finish callbacks as option arguments of its constructor
- Base effects (like Move, Size, etc.) can be called without from argument. Instead of passing element, fromPos, toPos, options as arguments, the effects can be called with element, toPos, options. The fromPos is calculated on the fly based on the current position.
- AppearFade, Blind, GrowShrink, Slide and Squish effects now can be triggered for initially invisible elements ('display:none' or 'visibility:hidden')
- Widgets
- Added Menu Bar widget
- Added Tabbed Panels widget
- Added Collapsible Panel widget
- Added Form Validation Widgets
- Accordion:
- Added support for variable height panels.
- Added some new constructor options:
- useFixedHeightPanels - This value is true by default. If false allows for variable height panels.
- fixedPanelHeight - Number of pixels to use as the height of each panel when animating. By default this is the same as the first open panel.
- duration - Number of milliseconds it takes to open/close a panel. Default is 500 msecs.
- Fixed bug that prevented panels from animating properly when the accordion started out with a display:none style.
- Removed addNewPanel(), getNewPanelSnippet(), getNewAccordionSnippet(), and getNewAccordionConstructorSnippet() methods. They don't work cross-browser, and should've never seen the light of day.
- Docs
- Added overview for Tabbed Panels widget.
- Added overview for Collapsible Panel widget.
- Added overview docs for each Form widget.
- Demos
- Gallery
- Switch from using an interval timer to manually firing off the slide show timer after each image loads. This will allow images loading over slow connections to completely load.
- Products
- index.html to use spry:sort and spry:setrow.
- Use a spry:choose attribute to show/preserve the currently selected product on initial load and after a sort.
- RSS Reader
- Modified index.{html,cfm,php} to use spry:setrow.
- Added Form Validation demo.
- Samples
- Added sample for Tabbed Panels widget.
- Added sample for Collapsible Panel widget.
- Added samples for 4 Form widgets.
- Moved data set and region examples to the samples/data_region folder.
- Changed Effects sample files to use standard samples.css file.
- Added a samples/utils folder with samples of Spry utility functions.
- Released a query-to-XML sample page that shows how to convert dynamic data into XML.
- Added to EvenOddRowSample.html to include spry:even and spry:odd.
- Added SprySetRowSample.html.
- Modified the AccordionSample:
- Added sample for changing the duration of animations.
- Modified variable height accordion sample to use animation.
- Added a style for spans used as content panels so that they animate properly.
- Added SetCurrentRowByValueSample.html to show how to select a row based on some column values.
- Added StateMappingSample.html to show how to map the built-in region states to your own custom states.
效果演示:
http://dannyr.nbdown.net/spry/index.html代码下载:
http://dannyr.nbdown.net/filtrate.zip说明:
代码是从Spain的MMUG拉下来的,MMUG上的是用Spry1.0,我按Spry1.3版本稍微做了修改。效果还不错,遗憾的是我的测试机上IE7和FireFox2的淡入淡出效果不一致,IE7的效果要好!同时由于动态显示数据集的区域(Region)内容是js动态生成的,在DataSet执行数据过滤后又重新填充并生成显示表,这样原先没过滤前显示区域的style效果就都丢失了,每次生成显示区域后区域里的style都是按默认值重新生成,所以每次过滤后显示区域的style效果都重置一次,没有连续性,很不如人意。
摘要: 简介: 新的Flex2.0类库里提供了文件类,方便了上传/下载文件。下面的程序demo演示了Flex2.0生成flash来访问本地文件,在flash里上传用户选择的文件到服务器,flash客户端可以处理文件上传进度等多个事件,服务器端是C#写的文件接收模块,把用户上传的文件保存在服务器上。 Demo演示了ProgressEvent.PROGRESS, Event.SELECT 2个事件的处理方法。...
阅读全文
摘要: 简介: Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,以HTML为中心,使用最基本的HTML、CSS和JavaScript来实现丰富Web页面体验。 本例子演示了数据集的字段排序功能以及对数据集排序时候触发的事件的处理;代码很简单,需要讲一下sort方法,sort方法有2个入口参数:字段名和排序顺序(ascending descending toggl...
阅读全文
简介:
Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,是一个包含JavaScript、CSS和图片文件的JavaScript库,必须在客户端浏览器中运行;支持XML数据集、动态区域显示、窗口显示部件和动态变换效果。
用过Flex的朋友们可以很容易的看出这个Spry框架结构有点像Flex,并且使用HTTPService来与后台服务通讯。的确这个框架感觉每个层面的耦合很松弛,如下图所示,服务器端可以使用现有的主流技术,展示页面上可以通过DOM直接整合HTML等,是比较容易在现有的系统上改造及嵌入;同时Spry框架的设计目标是Web设计者,对于开发人员来说很容易上手和集成。
框架及浏览器结构:

框架特点:
Spry框架是为Web设计设计者开发的,因此框架的每个元素都按以下原则设计:
* 保持轻巧
* 保持简单
o使用标准的HTML、CSS和JavaScript技术
o保持每个元素的所有属性/语法都绝对最小化
o尽可能的简化脚本编程
摘要: 简介: Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,以HTML为中心,使用最基本的HTML、CSS和JavaScript来实现丰富Web页面体验。试验环境:操作系统:windows2003 Server浏览器:IE7.0 RC1FireFox 1.5.0.7WEB服务器:IIS 6.0Spry库:Spry_P1_3_08-11安装:从http://l...
阅读全文
摘要: 简介: Spry Framework是Adobe出品的轻量级的支持Ajax的JavaScript库,以HTML为中心,使用最基本的HTML、CSS和JavaScript来实现丰富Web页面体验。试验环境:操作系统:windows2003 Server浏览器:IE7.0 RC1FireFox 1.5.0.7WEB服务器:IIS 6.0Spry库:Spry_P1_3_08-11安装:从http://l...
阅读全文
新的Visual Assist X增加了重构和代码搜索等功能,并支持C/C++、C#、VB。估计是目前VS上比较完善的工具了。原来C#的ReSharper和C++的Ref++都可以丢掉了。感觉比原来稍微重了一点!但还是很爽哦。
http://www.wholetomato.com/