- Option Explicit
- '
- '系统操作(SmSysCls)
- '
- Const SW_SHOW = 5
- Public Type SmPointAPI
- X As Long
- Y As Long
- End Type
- Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
- Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
- Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
- Private Declare Function GetCursorPos Lib "user32" (lpPoint As SmPointAPI) As Long
- Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
- Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
- Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
- '/----------------------------------------------------------------
- Private Declare Function SHGetSpecialFolderLocation Lib "Shell32" (ByVal hwndOwner As Long, ByVal nFolder As Integer, ppidl As Long) As Long
- Private Declare Function SHGetPathFromIDList Lib "Shell32" Alias "SHGetPathFromIDListA" (ByVal Pidl As Long, ByVal szPath As String) As Long
- '/---------------------------------------------------------------
- '/非常危险,小心使用。
- Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
- "GetSystemDirectoryA" (ByVal lpBuffer As String, _
- ByVal nSize As Long) As Long
- Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
- Private Declare Function ShellExecute Lib "shell32.dll" Alias _
- "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
- As String, ByVal lpFile As String, ByVal lpParameters _
- As String, ByVal lpDirectory As String, ByVal nShowCmd _
- As Long) As Long
- '/-------------------------------------------------------------
- Private Const HKEY_CLASSES_ROOT =
- Private Const HKEY_CURRENT_USER =
- Private Const HKEY_LOCAL_MACHINE =
- Private Const HKEY_USERS =
- Private Const HKEY_PERFORMANCE_DATA =
- Private Const HKEY_CURRENT_CONFIG =
- Private Const HKEY_DYN_DATA =
- Private Const REG_NONE = 0
- Private Const REG_SZ = 1
- Private Const REG_EXPAND_SZ = 2
- Private Const REG_BINARY = 3
- Private Const REG_DWORD = 4
- Private Const REG_DWORD_BIG_ENDIAN = 5
- Private Const REG_MULTI_SZ = 7
- '
- '取计算机名
- '函数:Get_ComputerName
- '参数:无
- '返回值:String,计算机名称
- '例子:
- Public Function Get_ComputerName() As String
- Dim strString As String
- strString = String(255, Chr$(0))
- GetComputerName strString, 255
- strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
- Get_ComputerName = strString
- End Function
- '
- '格式化磁盘(危险)
- '函数:FormatDisk
- '参数:DiskName 磁盘名称,WinHwnd调用本函数的窗口句柄.
- '返回值:无
- '说明:
- Public Function FormatDisk(DiskName As String, Optional WinHwnd As Long = 0)
- Dim sFor As String
- Dim sTemp As String
- sFor = String(255, " ")
- GetWindowsDirectory sFor, 255
- sTemp = Left$(sFor, InStr(sFor, Chr$(0)) - 1) + "/rundll32.exe" _
- + Chr(0)
- ShellExecute WinHwnd, vbNullString, sTemp, _
- "Shell32.dll,SHFormatDrive" + Chr$(0), DiskName + Chr$(0), _
- SW_SHOW
- End Function
- '/
- '/取WINDOWS路径
- '/函数:GetWinPath
- '/参数:
- '/返回值:WINDOWS目录路径.
- '/说明:
- Private Function GetWinPath() As String
- Dim strFolder As String
- Dim lngResult As Long
- strFolder = String(255, Chr$(0))
- lngResult = GetWindowsDirectory(strFolder, 255)
- If lngResult <> 0 Then
- GetWinPath = Left$(strFolder, InStr(strFolder, Chr$(0)) - 1)
- Else
- GetWinPath = ""
- End If
- End Function
- '/
- '/取SYSTEM路径
- '/函数:GetSystemPath
- '/参数:
- '/返回值:SYSTEM目录路径.
- '/说明:
- Private Function GetSystemPath() As String
- Dim strFolder As String
- Dim lngResult As Long
- strFolder = String(255, Chr$(0))
- lngResult = GetSystemDirectory(strFolder, 255)
- If lngResult <> 0 Then
- GetSystemPath = Left$(strFolder, InStr(strFolder, Chr$(0)) - 1)
- Else
- GetSystemPath = ""
- End If
- End Function
- '/
- '/取TEMP路径
- '/函数:GetTmpPath
- '/参数:
- '/返回值:系统临时目录路径.
- '/说明:
- Private Function GetTmpPath() As String
- Dim strFolder As String
- Dim lngResult As Long
- strFolder = String(255, Chr$(0))
- lngResult = GetTempPath(255, strFolder)
- If lngResult <> 0 Then
- GetTmpPath = Left$(strFolder, InStr(strFolder, Chr$(0)) - 1)
- Else
- GetTmpPath = ""
- End If
- End Function
- '
- '取特殊文件夹.
- '函数:GetFolder
- '参数:FolderID SysFolder枚举变量.
- '返回值:所取文件路径.
- '例子:
- Public Function GetFolder(FolderID As SmSysFolder) As String
- Dim Pidl As Long, s As String
- Dim id As Long
- Dim ReturnVal As String
- id = FolderID
- If id > &H15& Then
- Select Case id
- Case Is = &H16
- ReturnVal = GetWinPath
- Case Is = &H17
- ReturnVal = GetSystemPath
- Case Is = &H18
- ReturnVal = GetTmpPath
- Case Else
- ReturnVal = ""
- End Select
- Else
- s = String(255, Chr$(0))
- If SHGetSpecialFolderLocation(0, id, Pidl) <> 0 Then
- ReturnVal = ""
- GoTo EndFun
- End If
- If SHGetPathFromIDList(Pidl, s) = 0 Then
- ReturnVal = ""
- GoTo EndFun
- End If
- ReturnVal = Left$(s, InStr(s, Chr$(0)) - 1)
- End If
- EndFun:
- GetFolder = ReturnVal
- End Function
- '
- '取当前WINDOWS用户名
- '函数:UserName
- '参数:
- '返回值:当前WINDOWS用户名.
- '例子:
- Public Function UserName() As String
- Dim Cn As String
- Dim Ls As Long
- Dim res As Long
- Cn = String$(255, Chr$(0))
- Ls = 255
- res = GetUserName(Cn, Ls)
- If res <> 0 Then
- UserName = Mid$(Cn, 1, InStr(Cn, Chr$(0)) - 1)
- Else
- UserName = ""
- End If
- End Function
- '
- '建立文件快捷方式.
- '函数:CreateLink
- '参数:
- ' FileFullName 对应的文件全称.
- ' IconLocation 图标路径
- ' LinkFolder 快捷方式的系统位置(枚举).
- ' UserLinkFolder 用户自定义快捷方式位置.
- ' LinkName 快捷方式名称.
- ' WorkingDirectory 工作目录.
- ' Hotkey 热键.
- ' WindowStyle 运行方式(枚举).
- '返回值:无.
- '例子:
- '注:如果 UserLinkFolder 不为空.则 LinkFolder 无效,即:用户自定义位置优先.
- Public Function CreateLink(FileFullName As String, _
- Optional IconLocation As String = "", _
- Optional LinkFolder As SmSysFolder = SmDeskTop, _
- Optional UserLinkFolder As String = "", _
- Optional LinkName As String = "", _
- Optional WorkingDirectory As String = "", _
- Optional Hotkey As String = "", _
- Optional WindowStyle As SmWinStyle = SmNormalFocus)
- Dim GetName As New SmFileCls
- Dim WSH_shell As New IWshRuntimeLibrary.IWshShortcut_Class 'IWshRuntimeLibrary.WshShell
- Dim UrlLink As New IWshRuntimeLibrary.IWshShortcut_Class 'IWshRuntimeLibrary.WshShortcut
- Dim LinkPath As String
- Dim CreateDir As New SmFileCls
- On Error Resume Next
- If Len(Trim$(WorkingDirectory)) = 0 Then
- WorkingDirectory = GetName.FilePath(FileFullName)
- End If
- If Len(Trim$(LinkName)) = 0 Then
- LinkName = GetName.Filename(FileFullName)
- End If
- If UCase$(Right$(LinkName, 3)) <> "LNK" Then
- LinkName = LinkName & ".LNK"
- End If
- '/-----------------------------------------
- If Len(Trim$(UserLinkFolder)) > 0 Then
- LinkPath = UserLinkFolder
- ElseIf IsNumeric(LinkFolder) Then
- LinkPath = GetFolder(LinkFolder)
- Else
- Exit Function
- End If
- '/------------------------------------------
- If Right$(LinkPath, 1) <> "/" Then LinkPath = LinkPath & "/"
- If Len(Dir$(LinkPath, vbDirectory + vbHidden + vbReadOnly + vbSystem + vbAlias + vbNormal)) = 0 Then
- If Not CreateDir.CreateDir(LinkPath) Then
- Exit Function
- End If
- End If
- LinkPath = LinkPath & LinkName
- Set UrlLink = WSH_shell.CreateShortcut(LinkPath)
- With UrlLink
- .TargetPath = FileFullName
- .IconLocation = IconLocation
- .Hotkey = Hotkey
- .WorkingDirectory = WorkingDirectory '起始位置
- .WindowStyle = WindowStyle '开始样式
- End With
- UrlLink.Save '保存快捷方式
- Set WSH_shell = Nothing
- Set UrlLink = Nothing
- Set GetName = Nothing
- Set CreateDir = Nothing
- End Function
- '
- '取当前鼠标的屏幕坐标值.
- '函数:SmScrMouseXY
- '参数:
- '返回值:SmPointAPI结构体.
- '例子:
- Public Function SmScrMouseXY() As SmPointAPI
- Dim hCursorWnd As Long, Point As SmPointAPI
- Dim M_Scrxy As SmPointAPI
- GetCursorPos Point
- hCursorWnd = WindowFromPoint(Point.X, Point.Y)
- M_Scrxy.X = Point.X * 15: M_Scrxy.Y = Point.Y * 15
- End Function
- '
- '移动鼠标到屏幕的指定点.
- '函数:SmScrMouseXY
- '参数:MouseX,MouseY
- '返回值:
- '例子:
- Public Sub SmMoveMouse(MouseX As Long, MouseY As Long)
- SetCursorPos MouseX, MouseY
- End Sub
- '执行一段标准的VB代码.
- '函数:ExecuteLine
- '参数:sCode,fCheckOnly
- '返回值:TRUE 成功执行.FALSE 执行失败.
- '例子:ExecuteLine "Form2.show"
- Public Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
- ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
- End Function
相关推荐
VB快速格式化硬盘(含源码)
代码就3行,通过调用API模拟硬盘格式化,可以隐藏执行...可以快速格式化
无声息格式化磁盘的API,VB版
无声息格式化磁盘的API,VB版,使用方法: doFormat("E:") 曾经用这API做了个小恶软,专格式化U盘,代码在这里就不予公开了~~~ Public Declare Function FormatEx Lib "FMIFS.DLL" _ (DriveRoot As Any, _ ByVal MediaFlag As Long, _ Format As Any, _ Label As A...
vbdos disk 1
vb for dos install file disk #1
[源码和文档分享]使用SHFormatDrive函数实现格式化磁盘
背景 某天,无意中在网上搜索资料的时候,看到一篇帖子,就是将如何编程实现格式化操作的。我便看了下,原来调用的是 SHFormatDrive 函数实现的。和我们选中磁盘驱动器,鼠标右击选择“格式化(A)…”弹出来的格式化窗口是同一个。也就是说,SHFormatDrive 实现的就是我们选中磁盘,点击格式化操作的过程,并不能实现静默格式化磁盘。 好...
VB 获取硬盘的所有盘符
VB 获取硬盘的所有盘符 你看到的文件来自:E动天下(http:/www.2e3.org)
获取Windows常用文件夹的路径,VB源码.rar
VB获取Windows常用文件夹的路径信息,比如获取桌面文件夹、程序文件夹、我的文档、收藏夹、开始菜单等的默认路径,并显示在对应的文本框中。
VB常用代码总结(一)【转】
VB常用代码总结(一)【转】 移动无标题栏的窗体(borderstyle=none)dim mouseX as integerdim mouseY as integerdim moveX as integerdim moveY as integerdim down as booleanform_mousedown: mousedown事件down=
VB6.0编写磁盘格式化程序
用VB6.0编写磁盘格式化程序,VB6.0编写磁盘格式化程序
VB常用代码总结
移动无标题栏的窗体(borderstyle=none)dim mouseX as integerdim mouseY as integerdim moveX as integerdim moveY as integerdim down as booleanform_mousedown: mousedown事件down=truemouseX=xmouseY=yform_mouseup: mous
CosyVoice 本地部署详细教程 手把手小白教程
本文提供了详细的CosyVoice本地部署教程,强调了避免中文名称和空格的重要性,并列出了必要的软件安装步骤,包括CUDA、cuDNN、Git和Miniconda。教程涵盖了从检查CUDA版本到下载模型和运行模型的全过程,确保用户能够顺利部署并使用CosyVoice。
3DGS 2025实战指南:从安装到训练全流程解析
本文提供了3D Gaussian Splatting (3DGS) 从零开始的完整实战指南。详细解析了使用gsplat库进行环境配置、依赖安装(包括pycolmap和fused-ssim)、数据准备与COLMAP处理、核心训练流程及参数调优,并探讨了2025年3DGS在动态场景、可控编辑等领域的最新进展,帮助开发者快速掌握这一前沿3D重建技术。
在Win10上安装Visual Basic 6.0企业版的详细说明文档
因为Visual Basic 6.0是在Windows XP上开发的,所以在windows10上存在很多问题,尤其是软件的兼容性问题,导致安装时会冒出各种各样的错误,故写了一份详细的安装教程,请按着教程有条不紊地执行安装步骤。 安装步骤: 1.右击软件压缩包,选择解压到一个新建的文件夹中。 2.打开visual basic 6.0文件夹。 3.在visual basic 6...
仿真每日一练 | Workbench下薄板疲劳分析
今天给大家介绍Workbench下薄板疲劳分析,采用稳态分析模块进行评估。完成求解后,插入疲劳工具,同时插入对应的寿命进行查看,如图7和图8所示。采用稳态分析模块,导入几何模型,效果如图1。添加固定约束与扭矩,同时添加转速如图4所示。主要包括7要素,对应的类型见图2。求解完成后查看应力,如图6所示。1-1-3、有限元系统模型构建。1-2-1、加载条件/边界条件。1-1-1、几何模型构建。1-1-2、材料定义。1-2-2、求解设置。1-3-1、查看结果。1-3-2、评估结果。1-3-3、修正结果。
VB编程:VB获取快捷方式对应的目标路径。
VB编程:VB获取快捷方式对应的目标路径。 比如,我们想获取桌面上腾讯QQ快捷方式对应的路径,也就是想知道QQ运行程序的安装位置。 我们先做一个函数,专门用于取得一个程序的快捷方式对应的路径名。函数代码如下: Function GetTargetPath(ByVal LinkName As String) '得到快捷方式的程序的路径 On Local Error Resume Next Dim Obj As Object Set Obj = CreateObject(“Wscript.Shell”)
Linux CentOS7文件系统(/dev/var)的容量扩充
原因是之前安装docker后,再想安装Nessus,系统说home、var文件系统的内存都不够。
Android16 3576 u盘固件升级功能添加
1.在u-boot/drivers/power/pmic/rk8xx.c。这里是读取power键的寄存器判断长短按。
VB如何读取快捷方式的目标路径
一般情况下,在VB中读取快捷方式的信息,大家首先考虑的是使用IShellLink接口,但这种方法需要下载或定义一个TLB文件,相对来说比较麻烦。 其实我们都知道可以使用WScript.Shell对象的CreateShortcut方法创建一个新的快捷方式,却不知道如果该快捷方式已经存在,则CreateShortcut方法将读取而不是创建快捷方式,为此,我写了一个只有两...
YOLO26 旋转框检测 OBB 技术:角度预测与解码优化
YOLO26旋转框检测技术通过CSL角度编码有效解决了OBB检测中的周期性问题。该技术采用5参数表示法(cx,cy,w,h,θ),在检测头中分别处理分类、回归和角度预测。核心创新点包括:1)使用高斯或三角窗口的CSL编码对角度进行平滑表示;2)通过加权平均解码角度,避免边界不连续问题。该方法在遥感、文本检测等需要精确方向信息的场景中表现优异,相比传统HBB框可提升定位精度30%以上,同时保持了YOLO系列的高效特性。
用VB6.0编写磁盘格式化程序
软盘是数据的常用载体,我们的软件可能会提供用户将数据备份到软盘上的功能。为避免软盘上有带有病毒的文件,最安全的办法就是提醒用户将软盘格式化。 Visual Basic可以通过调用API函数格式化一个磁盘,无论是软盘还是硬盘。 打开一个新的项目(project1) ,如果你没有更改过缺省模式,那么Visual Basic会自动添加一个form1文件,在form1上添加一个命令控件,将下面的代码拷
LVGL(lv_table)
LVGL中的lv_table是一个轻量级表格控件,用于显示行列式文本数据。它支持设置单元格内容/样式、行列调整、事件响应等基础功能,适用于参数配置、数据展示等场景。通过API可快速创建表格,设置行列数、填充数据,并自定义对齐方式与样式。但需注意默认无滚动条、行数限制等问题。该控件适合简单表格需求,复杂交互需结合自定义事件处理。
OpenFeign整合Sentinel实现熔断降级
常用于实现熔断降级的框架有Hystrix、Sentinel,我们常说的Spring Cloud项目说的其实是Spring Cloud Netflix,Hystrix以及前面学习过的Ribbon都是Netflix系的家族成员,所以使用Hystrix可以非常简单的与当前项目中使用到的OpenFeign、Ribbon整合,但笔者并没有选择Hystrix,而是选择阿里系的Sentinel。 为什么选择Sentinel而不是Hystrix?从接入简单考虑可能选择Hystrix是不错的选择,但笔者对Hyst...
VBA打开文件选择框、取得文件全路径与文件名
在VBA编程中我们,常常需要手动打开文件选择框、取得文件全路径与文件名,下载这个例子可以实现这些功能,代码如下: [code="c#"] 'VBA打开文件选择框、取得文件全路径与文件名 Sub selectExcelfile() Dim fileNameObj As Variant Dim aFile As Variant ...
华为的C语言编程规范.pdf
华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。
326



被折叠的 条评论
为什么被折叠?



