| micheal 的个人资料游之晶莹日志列表网络 | 帮助 |
|
9月9日 Visual Basic程序 数学问题1.判断奇数\偶数 Function IsEven(num as Integer) as Boolean IsEven=if(num mod 2=0,True,False) '偶数返回True,奇数返回False end Function 2.判断一个数是不是素数 Function IsPrime(num as Integer) as Boolean '素数和1返回False,负数\合数和0返回True Dim i as Integer,sqr_num=sqr(num) If num<1 Then IsPrime=True ElseIf num=1 Then IsPrime=False Else For i=2 To sqr_num If num mod i=0 Then IsPrime=True Exit For End If IsPrime=False End If end Function 3.求最小公倍数 Function ComMul_min(num1 as Integer,num2 as Integer) as Integer dim i as integer If num1<num2 Then i=num1:num1=num2:num2=i i=num1 do if i mod num2=0 then ComMui_min=i i=i+num1 loop End Function 4.求最大公约数 算法一: Function ComDiv_max(num1 as Integer,num2 as Integer) as Integer dim i as integer If num1<num2 Then i=num1:num1=num2:num2=i i=num2 do if num1 maod i=0 and num2 mod i=0 then ComDiv_max=i i=i-1 loop End Function 算法二: 辗转相除法(暂空) 6.验证哥德巴赫猜想 返回值为一结构 Type Prime num1 as integer num2 as integer End Type 下面的程序去掉了验证参数的步骤(即假设参数已经是大于2的偶数),而且用到了前面判断素数的程序 Function GDBH(num as integer) as Prime Dim n as Prime,i as integer For i=2 to num/2 If not(IsPrime(i) and IsPrime(num-i)) Then n.num1=i:n.num2=num-i Exit For End If Next GDBH=n End Function 直接生成XML的Google SiteMap代码[ASP版本]ASP版本,需要空间的FSO支持
使用方法就不说了 <% Server.ScriptTimeout=50000 ' sitemap_gen.asp ' A simple script to automatically produce sitemaps for a webserver, in the Google Sitemap Protocol (GSP) ' by Francesco Passantino ' www.iteam5.net/francesco/sitemap ' v0.2 released 5 june 2005 (Listing a directory tree recursively improvement) ' ' BSD 2.0 license, ' http://www.opensource.org/licenses/bsd-license.php ' 收集整理: 重庆森林@im286.com session("server")="http://192.168.0.111" '你的域名 vDir = "/" '制作SiteMap的目录,相对目录(相对于根目录而言) set objfso = CreateObject("Scripting.FileSystemObject") root = Server.MapPath(vDir) 'response.ContentType = "text/xml" 'response.write "<?xml version='1.0' encoding='UTF-8'?>" 'response.write "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>" str = "<?xml version='1.0' encoding='UTF-8'?>" & vbcrlf str = str & "<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>" & vbcrlf Set objFolder = objFSO.GetFolder(root) 'response.write getfilelink(objFolder.Path,objFolder.dateLastModified) Set colFiles = objFolder.Files For Each objFile In colFiles 'response.write getfilelink(objFile.Path,objfile.dateLastModified) str = str & getfilelink(objFile.Path,objfile.dateLastModified) & vbcrlf Next ShowSubFolders(objFolder) 'response.write "</urlset>" str = str & "</urlset>" & vbcrlf set fso = nothing Set objStream = Server.CreateObject("ADODB.Stream") With objStream '.Type = adTypeText '.Mode = adModeReadWrite .Open .Charset = "utf-8" .Position = objStream.Size .WriteText=str .SaveToFile server.mappath("/sitemap.xml"),2 '生成的XML文件名 .Close End With Set objStream = Nothing If Not Err Then Response.Write("<script>alert('成功生成站点地图!');history.back();</script>") Response.End End If Sub ShowSubFolders(objFolder) Set colFolders = objFolder.SubFolders For Each objSubFolder In colFolders if folderpermission(objSubFolder.Path) then 'response.write getfilelink(objSubFolder.Path,objSubFolder.dateLastModified) str = str & getfilelink(objSubFolder.Path,objSubFolder.dateLastModified) & vbcrlf Set colFiles = objSubFolder.Files For Each objFile In colFiles 'response.write getfilelink(objFile.Path,objFile.dateLastModified) str = str & getfilelink(objFile.Path,objFile.dateLastModified) & vbcrlf Next ShowSubFolders(objSubFolder) end if Next End Sub Function getfilelink(file,datafile) file=replace(file,root,"") file=replace(file,"\","/") If FileExtensionIsBad(file) then Exit Function if month(datafile)<10 then filedatem="0" if day(datafile)<10 then filedated="0" filedate=year(datafile)&"-"&filedatem&month(datafile)&"-"&filedated&day(datafile) getfilelink = "<url><loc>"&server.htmlencode(session("server")&vDir&file)&"</loc><lastmod>"&filedate&"</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>" Response.Flush End Function Function Folderpermission(pathName) '需要过滤的目录(不列在SiteMap里面) PathExclusion=Array("\temp","\_vti_cnf","_vti_pvt","_vti_log","cgi-bin","\admin","\edu") Folderpermission =True for each PathExcluded in PathExclusion if instr(ucase(pathName),ucase(PathExcluded))>0 then Folderpermission = False exit for end if next End Function Function FileExtensionIsBad(sFileName) Dim sFileExtension, bFileExtensionIsValid, sFileExt 'modify for your file extension (http://www.googleguide.com/file_type.html) Extensions = Array("png","gif","jpg","jpeg","zip","pdf","ps","html","htm","php","wk1","wk2","wk3","wk4","wk5","wki","wks","wku","lwp","mw","xls","ppt","doc","swf","wks","wps","wdb","wri","rtf","ans","txt") '设置列表的文件名,扩展名不在其中的话SiteMap则不会收录该扩展名的文件 if len(trim(sFileName)) = 0 then FileExtensionIsBad = true Exit Function end if sFileExtension = right(sFileName, len(sFileName) - instrrev(sFileName, ".")) bFileExtensionIsValid = false 'assume extension is bad for each sFileExt in extensions if ucase(sFileExt) = ucase(sFileExtension) then bFileExtensionIsValid = True exit for end if next FileExtensionIsBad = not bFileExtensionIsValid End Function %> 几个bat例子文件下面几个bat文件示例,希望对你有点用处,根据需要自己修改一下再使用。
删除默认共享(别存为bat文件放在开始菜单中):net_share_delete.bat,删除默认共享的另一个种方法
登陆到局域网的机器快捷方式(对方机器有密码且为2000或以上系统)nethood.bat
批处理中的循环newfolder.bat
删除临时文件夹中的文件(window 2000或以上操作系统) del_tempfile.bat
解决IE无法在新窗口中打开链接的问题,关闭所有的ie窗口,运行下面内容的bat iedll.bat
重命名从IE临时文件夹中拷贝的文件 renameIEtempfile.bat(从Temporary Internet Files复制过来的文件都会在文件名上加上[1]或者[n],用此bat文件可以很快的给他们改名)
在Windows 2000/XP 下巧拒强行关机 从去年8月到现在,冲击波和震荡波让无数人的爱机无数次重启,折腾得要命。当然现在有了补丁,有了专杀工具,它们的威力已大大减弱。但还是常有一些人
遭受它们的毒害,由于重启不得不关闭看得正好的电影,中止运行处于关键阶段的程序,因而丢失重要的数据,让人痛恨不已!那么能不能阻止由冲击波和震荡波引
起的强制重启,先做完重要的工作,然后再去收拾这两个家伙呢? 为找到答案,我们有必要先了解一下WINDOWS XP的关机。Windows XP系统通过一个名为Shutdown.exe的程序来完成关机操作(位置在Windows\System下),一般情况下XP的关机是由关机程序 shutdown.exe来实现的,关机的时候调用shutdown.exe。由此可知要阻止强行关机就是要取消对shutdown.exe的调用。而笔 者发现冲击波和震荡波的关机重启都要调用这个程序,于是答案由此而生: 在弹出强行关机的对话框时,快速打开[运行]窗口(按下CTRL+R),输入“shutdown.exe -a”(注意有一个空格),回车,这时你可以看到强行关机的对话框消失了。然后就可以轻松地干掉冲击波和震荡波。 当然这种方法不仅可用于此,其它一些原因引起的关机也如法炮制。 既然谈到shutdown.exe,有必要将其它重要参数介绍一下: shutdown.exe -a 取消关机 shutdown.exe -f 强行关闭应用程序。 shutdown.exe -m \计算机名 控制远程计算机。 shutdown.exe -i 显示图形用户界面,但必须是Shutdown的第一个参数。 shutdown.exe -l 注销当前用户。 shutdown.exe -r 关机并重启。 shutdown.exe -t时间 设置关机倒计时。 shutdown.exe -c"消息内容" 输入关机对话框中的消息内容(不能超127个字符)。 比如你的电脑要在23:00关机,可以选择“开始→运行”,输入“at 23:00 Shutdown -s”,这样,到了23点,电脑就会出现“系统关机”对话框,默认有30秒钟的倒计时并提示你保存工作。如果你想以倒计时的方式关机,可以输入 “Shutdown.exe -s -t 3600”,这里表示60分钟后自动关机,“3600”代表60分钟。 如果想取消的话,可以在运行中输入“shutdown -a”。另外输入“shutdown -i”,则可以打开设置自动关机对话框,对自动关机进行设置。 虽然shutdown.exe是Windows XP下的程序,在Windows2000中是调用Windows下System中的Shell32.dll文件来实现关机的,例如“indir\ RunDLL32.exe indir\System\Shell32.dll,SHExitWindowsEx 8”,但在Win2000也可利用它,方法如下: 在WinXP安装目录下的System32文件夹中找到Shutdown.exe,将它复制到Win2000安装目录下的System32文件夹中,在“运行”中输入“Shutdown.exe”,即可像在Windows XP中一样使用该程序了。 当然,shutdown.exe还有一些强大的功能,读者可以进一步实践探讨,充分利用 shutdown.exe 的强大功能。 Windows XP Home Edition上安装IIS事前准备
1、Windows XP HomeEdit 中文版 CD(拷在硬盘也可以) 2、Windows 2000 Advanced Server CD(最好也是中文版) 3、默认你的XP是安装在C:\WINDOWS下 开始动手 (如果你怕改错,先把C:\WINDOWS\INF\SYSOC.INF做一份备份) 用记事本打开C:\WINDOWS\INF\SYSOC.INF,在[COMPONENTS]下找到一行: iis=iis.dll,OcEntry,iis.inf,hide,7 然后把它改成 iis=iis2.dll,OcEntry,iis2.inf,,7 保存。 然后把Windows 2000 Advanced Server CD里的两个文件IIS.DL_和IIS.IN_拷贝到一个临时的目录(例如C:\IISonXPHome),然后在命令提示符状态下将当前目录转到C:\IISonXPHome,执行 EXPAND IIS.DL_ IIS2.DLL EXPAND IIS.IN_ IIS2.INF 解出IIS2.DLL及IIS2.INF两个文件,将IIS2.INF复制到C:\WINDOWS\INF目录下,将IIS2.DLL 复制到C:\WINDOWS\SYSTEM32\SETUP目录下。 现在按“开始->设置->控制面板->添加或删除程序->添加/删除Windows组件”,这时你可以很兴奋地发现IIS出现了!!! 此后的过程就和PRO版的XP安装IIS差不多了,过程中复制文件时会多次要求你选择Windows 2000 Advanced Server光盘和Windows XP HomeEdit光盘的位置(都在I386中),输入指定的目录即可正常安装。 安装完毕以后还不能直接用的,需要对IIS进行一些设置: 控制面板->管理工具->Internet服务管理器 然后点“默认WEB站点”的右键,转到“目录安全性”选项卡,点“匿名访问和验证控制”的“编辑”按钮,回弹出匿名方法新窗口,再点击其中“匿名访问”中的“编辑”按钮,将“允许IIS控制密码”前面的勾去掉,然后一路确定返回即可。 超强在线翻译
最近发现由AltaVistahttp://www.altavista.com/ 提供的一项免费服务Babel Fish Translation http://babelfish.altavista.com/
更多功能我没深入研究.大家自己发掘吧. 9月6日 ASP远程注册DLL的方法<% Response.Buffer = True %> <% Server.ScriptTimeout = 500 Dim frmFolderPath, frmFilePath frmFolderPath = Request.Form("frmFolderPath") frmFilePath = Request.Form("frmDllPath") frmMethod = Request.Form("frmMethod") btnREG = Request.Form("btnREG") %> <HTML> <HEAD> <TITLE>Regsvr32.asp</TITLE> <STYLE TYPE="TEXT/CSS"> .Legend {FONT-FAMILY: veranda; FONT-SIZE: 14px; FONT-WEIGHT: bold; COLOR: blue} .FS {FONT-FAMILY: veranda; FONT-SIZE: 12px; BORDER-WIDTH: 4px; BORDER-COLOR: green; MARGIN-LEFT:2px; MARGIN-RIGHT:2px} TD {MARGIN-LEFT:6px; MARGIN-RIGHT:6px; PADDING-LEFT:12px; PADDING-RIGHT:12px} </STYLE> </HEAD> <BODY> <FORM NAME="regForm" METHOD="POST"> <TABLE BORDER=0 CELLSPACING=6 CELLPADDING=6 MARGINWIDTH=6> <TR> <TD VALIGN=TOP> <FIELDSET ID=FS1 NAME=FS1 CLASS=FS> <LEGEND CLASS=Legend>Regsvr Functions</LEGEND> Insert Path to DLL Directory <INPUT TYPE=TEXT NAME="frmFolderPath" VALUE="<%=frmFolderPath%>"> <INPUT TYPE=SUBMIT NAME=btnFileList VALUE="Build File List"> <% IF Request.Form("btnFileList") <> "" OR btnREG <> "" Then Set RegisterFiles = New clsRegister RegisterFiles.EchoB("<B>Select File</B>") Call RegisterFiles.init(frmFolderPath) RegisterFiles.EchoB(" <INPUT TYPE=SUBMIT NAME=btnREG VALUE=" & Chr(34) _ & "REG/UNREG" & Chr(34) & ">") IF Request.Form("btnREG") <> "" Then Call RegisterFiles.Register(frmFilePath, frmMethod) End IF Set RegisterFiles = Nothing End IF %> </FIELDSET> </TD> </TR> </TABLE> </FORM> </BODY> </HTML> <% Class clsRegister Private m_oFS Public Property Let oFS(objOFS) m_oFS = objOFS End Property Public Property Get oFS() Set oFS = Server.CreateObject("Scripting.FileSystemObject") End Property Sub init(strRoot) 'Root to Search (c:, d:, e:) Dim oDrive, oRootDir IF oFS.FolderExists(strRoot) Then IF Len(strRoot) < 3 Then 'Must Be a Drive Set oDrive = oFS.GetDrive(strRoot) Set oRootDir = oDrive.RootFolder Else Set oRootDir = oFS.GetFolder(strRoot) End IF Else EchoB("<B>Folder ( " & strRoot & " ) Not Found.") Exit Sub End IF setRoot = oRootDir Echo("<SELECT NAME=" & Chr(34) & "frmDllPath" & Chr(34) & ">") Call getAllDlls(oRootDir) EchoB("</SELECT>") BuildOptions End Sub Sub getAllDlls(oParentFolder) Dim oSubFolders, oFile, oFiles Set oSubFolders = oParentFolder.SubFolders Set opFiles = oParentFolder.Files For Each oFile in opFiles IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then Echo("<OPTION VALUE=" & Chr(34) & oFile.Path & Chr(34) & ">" _ & oFile.Name & "</Option>") End IF Next On Error Resume Next For Each oFolder In oSubFolders 'Iterate All Folders in Drive Set oFiles = oFolder.Files For Each oFile in oFiles IF Right(lCase(oFile.Name), 4) = ".dll" OR Right(lCase(oFile.Name), 4) = ".ocx" Then Echo("<OPTION VALUE=" & Chr(34) & oFile.Path & Chr(34) & ">" _ & oFile.Name & "</Option>") End IF Next Call getAllDlls(oFolder) Next On Error GoTo 0 End Sub Sub Register(strFilePath, regMethod) Dim theFile, strFile, oShell, exitcode Set theFile = oFS.GetFile(strFilePath) strFile = theFile.Path Set oShell = CreateObject ("WScript.Shell") IF regMethod = "REG" Then 'Register oShell.Run "c:\WINNT\system32\regsvr32.exe /s " & strFile, 0, False exitcode = oShell.Run("c:\WINNT\system32\regsvr32.exe /s " & strFile, 0, False) EchoB("regsvr32.exe exitcode = " & exitcode) Else 'unRegister oShell.Run "c:\WINNT\system32\regsvr32.exe /u/s " & strFile, 0, False exitcode = oShell.Run("c:\WINNT\system32\regsvr32.exe /u/s " & strFile, 0, False) EchoB("regsvr32.exe exitcode = " & exitcode) End IF Cleanup oShell End Sub Sub BuildOptions EchoB("Register: <INPUT TYPE=RADIO NAME=frmMethod VALUE=REG CHECKED>") EchoB("unRegister: <INPUT TYPE=RADIO NAME=frmMethod VALUE=UNREG>") End Sub Function Echo(str) Echo = Response.Write(str & vbCrLf) End Function Function EchoB(str) EchoB = Response.Write(str & " " & vbCrLf) End Function Sub Cleanup(obj) If isObject(obj) Then Set obj = Nothing End IF End Sub Sub Class_Terminate() Cleanup oFS End Sub End Class %> 错误80004005信息处理方法 1.错误信息(错误信息我不用翻译成中文了把,呵呵,大家谅解)
原因: 这个错误发生在当IIS使用匿名帐号(通常是IUSR)时,该帐号在NT中对数据库所在的目录没有正确的 权限.(这就是为什么在Win95和PWS下没问题,因为win95根本就没有目录权限这一说)检查文件和目录的权限. 确定你能够在该目录中有能够新建和删除临时文件的权限。 这些临时文件其实是数据库建立在同一个目录下的文件, 但是要注意的是,有可能这些文件 也可能建立在别的目录,例如 /Winnt. 使用NT的文件监视程序监视文件失败时到底是访问了什么目录。 这个NT的文件监视程序可以在这个地方下载http://www.sysinternals.com. 如果你对数据库使用了一个网络地址,例如映射地址,就要检查一下共享文件和目录的权限, 还要检查一下数据源文件(DSN)是否被别的程序标志成为正在使用中, 这些别的程序一般是Visual InterDev,关闭任何一个InterDev中的正打开和数据库连接的项目。 这个错误还可能发生在这种情况:如果在DSN中使用了一个UNC路径(就是通用命名协议),请改用本地路径进行测试,因为如果对本地数据库使用UNC也可能出错。 还可能发生在这种情况,如果服务器要访问Access中的一个表,而这个表却联接在一个网络服务器上。 2.错误信息:
原因: 多人使用时数据库被锁定。 3.错误信息:
原因: 最可能的原因是ConnectString是一个在global.asa中初始化的Session变量,但是global.asa 却没有正常工作。解决办法是,检查赋值时是否正确:(在你的asp中加入下面的代码) 还有一个原因就是你在你的ConnectString中加入了多余的空格,例如
试试改成下面这个样子:
如果是global.asa还没有工作,检查该文件是否在运用程序的根目录中,或者是虚拟目录的根目录中。 还有可能错误出现的原因是DSN名称没找着,这可以采用我提供的id=36767的办法解决。 最后是检查是否安装了最新的驱动程序,既是否是最新的MDAC版本。 4.错误信息
原因: 这个错误有可能是出现在你的计算机上软件安装(或则反安装)的顺序上。 如果ODBC的版本不一致的话,就会发生该错误。 解决办法是安装最新版本的MDAC 5.错误信息:
原因: 这个错误发生在爱从注册表中读取数值的时候。 使用regedit32.exe检查你的注册表的权限。 你也可以使用NT中的注册表监视程序(NTRegMon)来看读取失败信息。该程序到这找: http://www.sysinternals.com 6.错误信息:
原因: 两个原因:当一个数据库中包含有分别在不用机器上的许可关系时, 这也可能发生在同一台机器上,当你给一个关系设置了UNC路径,而另一个关系却是本地路径。 错误原因是: 当用户使用IIS匿名帐号登录后,对本地这台机器而言他是有权的,但是对于一个UNC路径的机器,另外这台机器是不会认为你当前匿名登录的帐号在它那上面也是合法的。这样它就不允许你访问它上面的资源,导致错误。 两个解决办法: 1.在IIS工具中,改变IIS匿名帐号成另外一个基于域的帐号。(也就是不使用匿名登录) 2.或则在那台你要访问资源的机器上也创建一个和当前匿名帐号同样的帐号,使用同样的密码。 7.错误信息
原因: 该错误是由SQL Server产生的,当它不接受或则不能够认识这个登录帐号的时候,或者没有使用管理员身份登录,也可能是在NT中没有SQL影射帐号造成的。 使用系统管理员帐号(SA)登录,一般密码应该为空.注意,这时必须使用CoonectString而不能够使用DSN文件。 因为DSN中没有保存用户名和密码。 检查NT是否给SQL映射了帐号。 8.错误信息
原因: 原因同上。 z 试试这个办法:在SQL Server的Enterprise Manager中,选择Server/SQL Server/Configure[ASCII 133]/Security Options/Standard. 如果是运行在IIS4中,取消选择该项目的Password Synchronization选项。 9.错误信息
原因: 也许是没有正确的权限生成Access数据库的锁定文件(.ldb) 默认时,该文件和你的数据库是同一个目录的。 给匿名帐号全权访问数据库共享目录的权限。 有时是因为文件是因为共享时有意使用了只读的权限限制。试试使用下面的代码。 Set Conn = Server.CreateObject("ADODB.Connection") Conn.Mode = adModeShareDenyWrite '8 10.错误信息
原因: 路径非法。最可能发生在当Global.asa和CoonecntString被使用到另外一台机器上的时候。 11.错误信息
原因: 查询太复杂了,对查询有限制。 12.错误信息:
原因: 当装有SQL Server的机器改名的时候。但是DSN还使用了原来的机器名。 ASP自动解压RAR文件 朋友给我个支持ASP的空间,但是在上传文件只能单个文件的上传,没有批量的上传,我的网页有许多的 细小图片,这种上传方式是很痛苦的。所以就考虑可不可以把图片文件都压缩为RAR格式,然后在服务器上解 压。 其实想实现这种功能很简单,首先要上传一个RAR的解压程序,就是RAR自己的解压程序,只需要它的核心 程序RAR.EXE这个文件就可以了。然后就要上传一个执行RAR.EXE的程序 CMD.EXE 这个是windows里的程序(不必我在多说了吧)。最后就开始执行这些程序了。看一下下面的代码
就是用Server.CreateObject("WScript.Shell")来执行CMD.EXE来运行RAR.EXE文件来解压RAR文件的。 以前不知道是否有前辈们发表过这些文章,但那位兄弟有兴趣的可以以用这种方法来实现诸多类似与这样的程序,希望你们可以找到一些更好的方法。 获得位图文件的信息在Form中添加一个Picture控件和一个CommandButton控件,在Picture控件中加入一个位图文件,将下面代码加入其中:
Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" _ (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) _ As Long Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, _ ByVal dwCount As Long, lpBits As Any) As Long Private Type BITMAP bmType As Long bmWidth As Long bmHeight As Long bmWidthBytes As Long bmPlanes As Integer bmBitsPixel As Integer bmBits As Long End Type Private Sub Command1_Click() Dim hBitmap As Long Dim res As Long Dim bmp As BITMAP Dim byteAry() As Byte Dim totbyte As Long, i As Long hBitmap = Picture1.Picture.Handle res = GetObject(hBitmap, Len(bmp), bmp) '取得BITMAP的结构 totbyte = bmp.bmWidthBytes * bmp.bmHeight '总共要多少BYTE来存图 ReDim byteAry(totbyte - 1) '将Picture1中的图信息存到ByteAry res = GetBitmapBits(hBitmap, totbyte, byteAry(0)) Debug.Print "Total Bytes Copied :"; res Debug.Print "bmp.bmBits "; bmp.bmBits Debug.Print "bmp.bmBitsPixel "; bmp.bmBitsPixel '每相素位数 Debug.Print "bmp.bmHeight "; bmp.bmHeight '以相素计算图象高度 Debug.Print "bmp.bmPlanes "; bmp.bmPlanes Debug.Print "bmp.bmType "; bmp.bmType Debug.Print "bmp.bmWidth "; bmp.bmWidth '以相素计算图形宽度 Debug.Print "bmp.bmWidthBytes "; bmp.bmWidthBytes '以字节计算的每扫描线长度 End Sub 40种网页常用小技巧(javascript)1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键 <table border oncontextmenu=return(false)><td>no</table> 可用于Table 2. <body onselectstart="return false"> 取消选取、防止复制 3. onpaste="return false" 不准粘贴 4. oncopy="return false;" oncut="return false;" 防止复制 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标 7. <input style="ime-mode:disabled"> 关闭输入法 8. 永远都会带着框架 <script language="JavaScript"><!-- if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页 // --></script> 9. 防止被人frame <SCRIPT LANGUAGE=JAVASCRIPT><!-- if (top.location != self.location)top.location=self.location; // --></SCRIPT> 10. 网页将不能被另存为 <noscript><iframe src=*.html></iframe></noscript> 11. <input type=button value=查看网页源代码 onclick="window.location = "view-source:"+ "http://www.pconline.com.cn""> 12.删除时确认 <a href="javascript:if(confirm("确实要删除吗?"))location="boos.asp?&areyou=删除&page=1"">删除</a> 13. 取得控件的绝对位置 //Javascript <script language="Javascript"> function getIE(e){ var t=e.offsetTop; var l=e.offsetLeft; while(e=e.offsetParent){ t+=e.offsetTop; l+=e.offsetLeft; } alert("top="+t+"/nleft="+l); } </script> //VBScript <script language="VBScript"><!-- function getIE() dim t,l,a,b set a=document.all.img1 t=document.all.img1.offsetTop l=document.all.img1.offsetLeft while a.tagName<>"BODY" set a = a.offsetParent t=t+a.offsetTop l=l+a.offsetLeft wend msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置" end function --></script> 14. 光标是停在文本框文字的最后 <script language="javascript"> function cc() { var e = event.srcElement; var r =e.createTextRange(); r.moveStart("character",e.value.length); r.collapse(true); r.select(); } </script> <input type=text name=text1 value="123" onfocus="cc()"> 15. 判断上一页的来源 javascript: document.referrer 16. 最小化、最大化、关闭窗口 <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Minimize"></object> <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Maximize"></object> <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <PARAM NAME="Command" VALUE="Close"></OBJECT> <input type=button value=最小化 onclick=hh1.Click()> <input type=button value=最大化 onclick=hh2.Click()> <input type=button value=关闭 onclick=hh3.Click()> 本例适用于IE 17.屏蔽功能键Shift,Alt,Ctrl <script> function look(){ if(event.shiftKey) alert("禁止按Shift键!"); //可以换成ALT CTRL } document.onkeydown=look; </script> 18. 网页不会被缓存 <META HTTP-EQUIV="pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 或者<META HTTP-EQUIV="expires" CONTENT="0"> 19.怎样让表单没有凹凸感? <input type=text style="border:1 solid #000000"> 或 <input type=text style="border-left:none; border-right:none; border-top:none; border-bottom: 1 solid #000000"></textarea> 20.<div><span>&<layer>的区别? <div>(division)用来定义大段的页面元素,会产生转行 <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行 <layer>是ns的标记,ie不支持,相当于<div> 21.让弹出窗口总是在最上面: <body onblur="this.focus();"> 22.不要滚动条? 让竖条没有: <body style="overflow:scroll;overflow-y:hidden"> </body> 让横条没有: <body style="overflow:scroll;overflow-x:hidden"> </body> 两个都去掉?更简单了 <body scroll="no"> </body> 23.怎样去掉图片链接点击后,图片周围的虚线? <a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a> 24.电子邮件处理提交表单 <form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain"> <input type=submit> </form> 25.在打开的子窗口刷新父窗口的代码里如何写? window.opener.location.reload() 26.如何设定打开页面的大小 <body onload="top.resizeTo(300,200);"> 打开页面的位置<body onload="top.moveBy(300,200);"> 27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 <STYLE> body {background-image:url(logo.gif); background-repeat:no-repeat; background-position:center;background-attachment: fixed} </STYLE> 28. 检查一段字符串是否全由数字组成 <script language="Javascript"><!-- function checkNum(str){return str.match(//D/)==null} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // --></script> 29. 获得一个窗口的大小 document.body.clientWidth; document.body.clientHeight 30. 怎么判断是否是字符 if (/[^/x00-/xff]/g.test(s)) alert("含有汉字"); else alert("全是字符"); 31.TEXTAREA自适应文字行数的多少 <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"> </textarea> 32. 日期减去天数等于第二个日期 <script language=Javascript> function cc(dd,dadd) { //可以加上错误处理 var a = new Date(dd) a = a.valueOf() a = a - dadd * 24 * 60 * 60 * 1000 a = new Date(a) alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日") } cc("12/23/2002",2) </script> 33. 选择了哪一个Radio <HTML><script language="vbscript"> function checkme() for each ob in radio1 if ob.checked then window.alert ob.value next end function </script><BODY> <INPUT name="radio1" type="radio" value="style" checked>Style <INPUT name="radio1" type="radio" value="barcode">Barcode <INPUT type="button" value="check" onclick="checkme()"> </BODY></HTML> 34.脚本永不出错 <SCRIPT LANGUAGE="JavaScript"> <!-- Hide function killErrors() { return true; } window.onerror = killErrors; // --> </SCRIPT> 35.ENTER键可以让光标移到下一个输入框 <input onkeydown="if(event.keyCode==13)event.keyCode=9"> 36. 检测某个网站的链接速度: 把如下代码加入<body>区域中: <script language=Javascript> tim=1 setInterval("tim++",100) b=1 var autourl=new Array() autourl[1]="www.njcatv.net" autourl[2]="javacool.3322.net" autourl[3]="www.sina.com.cn" autourl[4]="www.nuaa.edu.cn" autourl[5]="www.cctv.com" function butt(){ document.write("<form name=autof>") for(var i=1;i<autourl.length;i++) document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br>") document.write("<input type=submit value=刷新></form>") } butt() function auto(url){ document.forms[0]["url"+b].value=url if(tim>200) {document.forms[0]["txt"+b].value="链接超时"} else {document.forms[0]["txt"+b].value="时间"+tim/10+"秒"} b++ } function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1 onerror=auto("http://"+autourl+"")>")} run()</script> 37. 各种样式的光标 auto :标准光标 default :标准箭头 hand :手形光标 wait :等待光标 text :I形光标 vertical-text :水平I形光标 no-drop :不可拖动光标 not-allowed :无效光标 help :?帮助光标 all-scroll :三角方向标 move :移动标 crosshair :十字标 e-resize n-resize nw-resize w-resize s-resize se-resize sw-resize 38.页面进入和退出的特效 进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)"> 推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)"> 这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为 1-23: 0 矩形缩小 1 矩形扩大 2 圆形缩小 3 圆形扩大 4 下到上刷新 5 上到下刷新 6 左到右刷新 7 右到左刷新 8 竖百叶窗 9 横百叶窗 10 错位横百叶窗 11 错位竖百叶窗 12 点扩散 13 左右到中间刷新 14 中间到左右刷新 15 中间到上下 16 上下到中间 17 右下到左上 18 右上到左下 19 左上到右下 20 左下到右上 21 横条 22 竖条 23 以上22种随机选择一种 39.在规定时间内跳转 <META http-equiv=V="REFRESH" content="5;URL=http://www.51js.com"> 40.网页是否被检索 <meta name="ROBOTS" content="属性值"> 其中属性值有以下一些: 属性值为"all": 文件将被检索,且页上链接可被查询; 属性值为"none": 文件不被检索,而且不查询页上的链接; 属性值为"index": 文件将被检索; 属性值为"follow": 查询页上的链接; 属性值为"noindex": 文件不检索,但可被查询链接; 属性值为"nofollow": 文件不被检索,但可查询页上的链接。 23:59 | 固定链接 | 评论 (0) | 引用通告 (0) | 记录它 | 编程 固定链接 关闭 http://spaces.msn.com/members/michealyou/Blog/cns!1pggoFE-U_jkitH19EPRFqEw!191.entry 20个经典ASP代码 1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键 <table border oncontextmenu=return(false)><td>no</table> 可用于Table 2. <body onselectstart="return false"> 取消选取、防止复制 3. onpaste="return false" 不准粘贴 4. oncopy="return false;" oncut="return false;" 防止复制 5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标 6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标 7. <input style="ime-mode:disabled"> 关闭输入法 8. 永远都会带着框架 <script language="javascript"><!-- if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页 // --></script> 9. 防止被人frame <SCRIPT LANGUAGE=javascript><!-- if (top.location != self.location)top.location=self.location; // --></SCRIPT> 10. <noscript><iframe src=*.html></iframe></noscript> 网页将不能被另存为 11. <input type=button value=查看网页源代码 onclick="window.location = 'view-source:'+ 'http://www.csdn.net/'"> 12. 怎样通过asp的手段来检查来访者是否用了代理 <% if Request.ServerVariables("HTTP_X_FORWARDED_FOR")<>"" then response.write "<font color=#FF0000>您通过了代理服务器,"& _ "真实的IP为"&Request.ServerVariables("HTTP_X_FORWARDED_FOR") end if %> 13. 取得控件的绝对位置 //javascript <script language="javascript"> function getIE(e){ var t=e.offsetTop; var l=e.offsetLeft; while(e=e.offsetParent){ t+=e.offsetTop; l+=e.offsetLeft; } alert("top="+t+"\nleft="+l); } </script> //VBScript <script language="VBScript"><!-- function getIE() dim t,l,a,b set a=document.all.img1 t=document.all.img1.offsetTop l=document.all.img1.offsetLeft while a.tagName<>"BODY" set a = a.offsetParent t=t+a.offsetTop l=l+a.offsetLeft wend msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置" end function --></script> 14. 光标是停在文本框文字的最后 <script language="javascript"> function cc() { var e = event.srcElement; var r =e.createTextRange(); r.moveStart('character',e.value.length); r.collapse(true); r.select(); } </script> <input type=text name=text1 value="123" onfocus="cc()"> 15. 判断上一页的来源 asp: request.servervariables("HTTP_REFERER") javascript: document.referrer 16. 最小化、最大化、关闭窗口 <object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Minimize"></object> <object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Maximize"></object> <OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"> <PARAM NAME="Command" value="Close"></OBJECT> <input type=button value=最小化 onclick=hh1.Click()> <input type=button value=最大化 onclick=hh2.Click()> <input type=button value=关闭 onclick=hh3.Click()> 本例适用于IE 17. <% '定义数据库连接的一些常量 Const adOpenForwardOnly = 0 '游标只向前浏览记录,不支持分页、Recordset、BookMark Const adOpenKeyset = 1 '键集游标,其他用户对记录说做的修改将反映到记录集中,但其他用户增加或删除记录不会反映到记录集中。支持分页、Recordset、BookMark Const adOpenDynamic = 2 '动态游标功能最强,但耗资源也最多。用户对记录说做的修改,增加或删除记录都将反映到记录集中。支持全功能浏览(ACCESS不支持)。 Const adOpenStatic = 3 '静态游标,只是数据的一个快照,用户对记录说做的修改,增加或删除记录都不会反映到记录集中。支持向前或向后移动 Const adLockReadOnly = 1 '锁定类型,默认的,只读,不能作任何修改 Const adLockPessimistic = 2 '当编辑时立即锁定记录,最安全的方式 Const adLockOptimistic = 3 '只有在调用Update方法时才锁定记录集,而在此前的其他操作仍可对当前记录进行更改、插入和删除等 Const adLockBatchOptimistic = 4 '当编辑时记录不会被锁定,而更改、插入和删除是在批处理方式下完成的 Const adCmdText = &H0001 Const adCmdTable = &H0002 %> 18. 网页不会被缓存 HTM网页 <META HTTP-EQUIV="pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"> <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 或者<META HTTP-EQUIV="expires" CONTENT="0"> ASP网页 Response.Expires = -1 Response.ExpiresAbsolute = Now() - 1 Response.cachecontrol = "no-cache" PHP网页 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); 19. 检查一段字符串是否全由数字组成 <script language="javascript"><!-- function checkNum(str){return str.match(/\D/)==null} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // --></script> 20. 获得一个窗口的大小 document.body.clientWidth,document.body.clientHeight 21. 怎么判断是否是字符 if (/[^\x00-\xff]/g.test(s)) alert("含有汉字"); else alert("全是字符"); 22.TEXTAREA自适应文字行数的多少 <textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"> </textarea> 23. 日期减去天数等于第二个日期 <script language=javascript> function cc(dd,dadd) { //可以加上错误处理 var a = new Date(dd) a = a.valueOf() a = a - dadd * 24 * 60 * 60 * 1000 a = new Date(a) alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日") } cc("12/23/2002",2) </script> 24. 选择了哪一个Radio <HTML><script language="vbscript"> function checkme() for each ob in radio1 if ob.checked then window.alert ob.value next end function </script><BODY> <INPUT name="radio1" type="radio" value="style" checked>Style <INPUT name="radio1" type="radio" value="barcode">Barcode <INPUT type="button" value="check" onclick="checkme()"> </BODY></HTML> 25.获得本页url的request.servervariables("")集合 Response.Write "<TABLE border=1><!-- Table Header --><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>" for each ob in Request.ServerVariables Response.Write "<TR><TD>"&ob&"</TD><TD>"&Request.ServerVariables(ob)&"</TD></TR>" next Response.Write "</TABLE>" 26. 本机ip<%=request.servervariables("remote_addr")%> 服务器名<%=Request.ServerVariables("SERVER_NAME")%> 服务器IP<%=Request.ServerVariables("LOCAL_ADDR")%> 服务器端口<%=Request.ServerVariables("SERVER_PORT")%> 服务器时间<%=now%> IIS版本<%=Request.ServerVariables"SERVER_SOFTWARE")%> 脚本超时时间<%=Server.ScriptTimeout%> 本文件路径<%=server.mappath(Request.ServerVariables("SCRIPT_NAME"))%> 服务器CPU数量<%=Request.ServerVariables("NUMBER_OF_PROCESSORS")%> 服务器解译引擎<%=ScriptEngine & "/"& ScriptEngineMajorVersion &"."&ScriptEngineMinorVersion&"."& ScriptEngineBuildVersion %> 服务器操作系统<%=Request.ServerVariables("OS")%> 27.ENTER键可以让光标移到下一个输入框 <input onkeydown="if(event.keyCode==13)event.keyCode=9"> 28. 检测某个网站的链接速度: 把如下代码加入<body>区域中: <script language=javascript> tim=1 setInterval("tim++",100) b=1 var autourl=new Array() autourl[1]="www.njcatv.net" autourl[2]="javacool.3322.net" autourl[3]="www.sina.com.cn" autourl[4]="www.nuaa.edu.cn" autourl[5]="www.cctv.com" function butt(){ document.write("<form name=autof>") for(var i=1;i<autourl.length;i++) document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br/>") document.write("<input type=submit value=刷新></form>") } butt() function auto(url){ document.forms[0]["url"+b].value=url if(tim>200) {document.forms[0]["txt"+b].value="链接超时"} else {document.forms[0]["txt"+b].value="时间"+tim/10+"秒"} b++ } function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1 onerror=auto('http://";;;;+autourl+"')>")} run()</script> 29. 各种样式的光标 auto :标准光标 default :标准箭头 hand :手形光标 wait :等待光标 text :I形光标 vertical-text :水平I形光标 no-drop :不可拖动光标 not-allowed :无效光标 help :?帮助光标 all-scroll :三角方向标 move :移动标 crosshair :十字标 e-resize n-resize nw-resize w-resize s-resize se-resize sw-resize 1.本地无缓存,每次自动刷新 response.expires=0 response.addHeader "pragma" , "no-cache" response.addHeader "cache-control" , "private" 2.修改contentType并下载gif等格式 <% function dl(f,n) on error resume next set s=CreateObject("Adodb.Stream") S.Mode=3 S.Type=1 S.Open s.LoadFromFile(server.mappath(f)) if err.number>0 then response.write err.number & ":" & err.description else response.contentType="application/x-gzip" response.addheader "Content-Disposition:","attachment; filename=" & n response.binarywrite(s.Read(s.size)) end if end function call dl("012922501.gif","t1.gif") %> 19. 检查一段字符串是否全由数字组成 <script language="javascript"><!-- function checkNum(str){return !/\D/.test(str)} alert(checkNum("1232142141")) alert(checkNum("123214214a1")) // --></script> 20. 获得一个窗口的大小 document.body.clientWidth,document.body.clientHeight document.body.offsetWidth,document.body.offsetHeight 有时还需要知道window.screenTop,window.screenLeft 5月20日 Student 2006 已经开始Beta测试! 5月18日 “新CIH(Win32.Yami)”病毒专杀工具
新版CIH出现 感染NT代码成为可能 Real Alternative 1.38 好东西—微软官方的PPC模拟器
|
|
|