- 浏览: 174769 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
xiangyufangai:
很好很强大膜拜中哈哈!!
VB 两个字符串处理函数(类似Left/Mid/Right/Split的结合) -
hellohank:
这个……叫摘要算法,不叫加密算法~
Java实现的加密工具类(支持MD5和SHA) -
NIUCH1029291561:
接口有问题奥
网银在线支付接口和应用 -
yeuego:
能幫你就行了
MySQL索引分析 -
ForgiDaved:
很给力的介绍。记得前段时间给一个系统加功能,设计的表没有 ...
MySQL索引分析
Option Explicit
'
' APIs needed to manipulate the RAW SID
'
Declare Function AllocateAndInitializeSid Lib "advapi32.dll" _
(pIdentifierAuthority As SID_IDENTIFIER_AUTHORITY, _
ByVal nSubAuthorityCount As Byte, ByVal nSubAuthority0 As Long, _
ByVal nSubAuthority1 As Long, ByVal nSubAuthority2 As Long, _
ByVal nSubAuthority3 As Long, ByVal nSubAuthority4 As Long, _
ByVal nSubAuthority5 As Long, ByVal nSubAuthority6 As Long, _
ByVal nSubAuthority7 As Long, lpPSid As Long) As Long
Declare Sub FreeSid Lib "advapi32.dll" (ByVal pSid As Long)
Declare Function LookupAccountSid Lib "advapi32.dll" _
Alias "LookupAccountSidA" (ByVal lpSystemName As String, _
ByVal Sid As Long, ByVal Name As String, cbName As Long, _
ByVal ReferencedDomainName As String, _
cbReferencedDomainName As Long, peUse As Integer) As Long
Private Declare Function InitializeSid Lib "advapi32.dll" _
(ByVal Sid As Long, ByVal pIndentifierAuthority As Long, _
ByVal nSubAuthorityCount As Byte) As Long
Private Declare Function GetSidSubAuthority Lib "advapi32.dll" _
(ByVal Sid As Long, ByVal nSubAuthority As Long) As Long
Private Declare Function GetSidSubAuthorityCount Lib "advapi32.dll" _
(ByVal Sid As Long) As Long
Private Declare Function GetSidIdentifierAuthority Lib "advapi32.dll" _
(ByVal Sid As Long) As Long
Private Declare Function GetSidLengthRequired Lib "advapi32.dll" _
(ByVal nSubAuthorityCount As Byte) As Long
'
' APIs needed to manipulate pointers in VB
'
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
Private Declare Sub CopyDWORDFromPtr Lib "kernel32" Alias "RtlMoveMemory" _
(ByVal hpvDest As Long, ByVal hpvSource As Long, _
ByVal cbCopy As Long)
Private Declare Sub CopyDWORD Lib "kernel32" Alias "RtlMoveMemory" _
(ByVal hpvDest As Long, hpvSource As Long, ByVal cbCopy As Long)
Private Declare Function GetProcessHeap Lib "kernel32" () As Long
Private Declare Function HeapAlloc Lib "kernel32" (ByVal hHeap As Long, _
ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _
ByVal dwFlags As Long, ByVal lpMem As Long) As Long
'
' APIs, structures, and constants necessary to obtain the domain SID
'
Private Declare Function NetApiBufferFree Lib "netapi32" _
(ByVal Buffer As Long) As Long
Private Declare Function NetUserModalsGet Lib "netapi32" _
(ByVal serverName As Long, ByVal level As Long, _
BufPtr As Long) As Long
Type USER_MODALS_INFO_2
usrmod2_domain_name As Long
usrmod2_domain_id As Long
End Type
Public Const NERR_Success = 0
'
' Constants from WINNT.H for the various well-known SIDs, users and groups
'
Public Const SECURITY_WORLD_SID_AUTHORITY = &H1
Public Const SECURITY_NT_AUTHORITY = &H5
Public Const SECURITY_BUILTIN_DOMAIN_RID = &H20&
Public Const DOMAIN_ALIAS_RID_ADMINS = &H220&
Public Const DOMAIN_ALIAS_RID_USERS = &H221&
Public Const SECURITY_LOCAL_SYSTEM_RID = &H12
Public Const SECURITY_WORLD_RID = &H0
Public Const DOMAIN_USER_RID_ADMIN = &H1F4
Public Const DOMAIN_USER_RID_GUEST = &H1F5
Public Const DOMAIN_GROUP_RID_ADMINS = &H200
Type SID_IDENTIFIER_AUTHORITY
Value(6) As Byte
End Type
'
' Helper function to lookup a SID and display the name as a test
'
Public Sub DisplayNameOfSid(ByVal lSid As Long)
Dim result As Long
Dim userName As String
Dim cbUserName As Long
Dim domainName As String
Dim cbDomainName As Long
Dim peUse As Integer
' Lookup the constructed SID to get the name
userName = Space(255)
domainName = Space(255)
cbUserName = 255
cbDomainName = 255
result = LookupAccountSid(vbNullString, lSid, userName, cbUserName, _
domainName, cbDomainName, peUse)
If result <> 0 Then
MsgBox userName
End If
End Sub
Public Function GetWellKnownUserSIDFromRID(ByVal Rid As Long) As Long
Dim userInfo As USER_MODALS_INFO_2
Dim wszServerName() As Byte
Dim BufPtr As Long
Dim result As Long
Dim pSid As Long
Dim Index, Count As Long
Dim SubAuthorityCount As Byte
Dim domainName As String
Dim cbDomainName As Long
Dim peUse As Integer
Dim srcPtr As Long
Dim dstPtr As Long
GetWellKnownUserSIDFromRID = 0
' Get the SID of the local machine
result = NetUserModalsGet(ByVal 0&, 2, BufPtr)
If result <> NERR_Success Then
GetWellKnownUserSIDFromRID = 0
Exit Function
End If
' Copy the data in the buffer into USER_MODALS_INFO_2 structure
CopyMemory userInfo, BufPtr, Len(userInfo)
' Allocate storage for the new Sid: account domain Sid + account Rid
CopyMemory SubAuthorityCount, _
GetSidSubAuthorityCount(userInfo.usrmod2_domain_id), 1
Count = SubAuthorityCount
pSid = HeapAlloc(GetProcessHeap(), 0, _
GetSidLengthRequired(SubAuthorityCount + 1))
If pSid <> 0 Then
If InitializeSid(pSid, _
GetSidIdentifierAuthority(userInfo.usrmod2_domain_id), _
SubAuthorityCount + 1) <> 0 Then
' Copy the existing subauthorities from the account domain Sid
' into the new Sid
For Index = 0 To Count - 1
dstPtr = GetSidSubAuthority(pSid, Index)
srcPtr = GetSidSubAuthority(userInfo.usrmod2_domain_id, Index)
CopyDWORDFromPtr dstPtr, srcPtr, 4
Next Index
' append Rid to new Sid
dstPtr = GetSidSubAuthority(pSid, Index)
CopyDWORD dstPtr, Rid, 4
End If
End If
NetApiBufferFree BufPtr
GetWellKnownUserSIDFromRID = pSid
End Function
Public Sub ConstructWellKnownUserSids()
Dim lSid As Long
' Construct SID for Well-known user "Administrator"
lSid = GetWellKnownUserSIDFromRID(DOMAIN_USER_RID_ADMIN)
If lSid <> 0 Then
' Use the constructed SID in the application
DisplayNameOfSid lSid
' Free the heap memory block allocated in
' GetWellKnownUserSIDFromRID function for the SID
HeapFree GetProcessHeap(), 0, lSid
End If
' Construct SID for Well-known user "Guest"
lSid = GetWellKnownUserSIDFromRID(DOMAIN_USER_RID_GUEST)
If lSid <> 0 Then
' Use the constructed SID in the application
DisplayNameOfSid lSid
' Free the heap memory block allocated in
' GetWellKnownUserSIDFromRID VB function for the SID
HeapFree GetProcessHeap(), 0, lSid
End If
End Sub
Public Sub ConstructUniversalAndNTWellKnownSids()
Dim result As Long
Dim siaNtAuthority As SID_IDENTIFIER_AUTHORITY
Dim lSid As Long
' Construct SID for System "NT well-known SID"
siaNtAuthority.Value(5) = SECURITY_NT_AUTHORITY
result = AllocateAndInitializeSid(siaNtAuthority, 1, _
SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0, lSid)
' Use the constructed SID in the application
DisplayNameOfSid lSid
' Free the memory allocated for the SID using FreeSid() API
FreeSid lSid
' Construct SID for Everyone "Universal well-known SID"
siaNtAuthority.Value(5) = SECURITY_WORLD_SID_AUTHORITY
result = AllocateAndInitializeSid(siaNtAuthority, 1, _
SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, lSid)
' Use the constructed SID in the application
DisplayNameOfSid lSid
' Free the memory allocated for the SID using FreeSid() API
FreeSid lSid
' Construct SID for Administrators "Well-known group"
siaNtAuthority.Value(5) = SECURITY_NT_AUTHORITY
result = AllocateAndInitializeSid(siaNtAuthority, 2, _
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, _
0, 0, 0, 0, 0, 0, lSid)
' Use the constructed SID in the application
DisplayNameOfSid (lSid)
' Free the memory allocated for the SID using FreeSid() API
FreeSid lSid
' Construct SID for Users "Well-known group"
siaNtAuthority.Value(5) = SECURITY_NT_AUTHORITY
result = AllocateAndInitializeSid(siaNtAuthority, 2, _
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_USERS, _
0, 0, 0, 0, 0, 0, lSid)
' Use the constructed SID in the application
DisplayNameOfSid lSid
' Free the memory allocated for the SID using FreeSid() API
FreeSid lSid
End Sub
发表评论
-
vb 启动外部程序并且模拟鼠标点击
2011-03-09 13:28 1166Imports System.Runtime.InteropS ... -
VB 列出SQL数据库中所有表及字段信息
2011-03-09 13:24 1156程序思想:用Select name From sysobje ... -
VB 纯代码实现Timer控件的功能
2011-03-09 13:23 1356本博客有一篇类似的文章《VB 中运用 TimeSetEvent ... -
VB 控制音量
2011-03-09 13:22 1233'按钮一是音量增加,按钮二是音量减少,按钮三是静音切换. ... -
拦截 VB TextBox 双击消息
2011-03-09 13:22 949我们都知道在VB中TextBox默认是没有双击消息过程的(也就 ... -
VB 获取/设置屏幕分辨率
2011-03-09 13:21 1115Option ExplicitPrivate Decla ... -
VB 将数据快速导入EXCEL
2011-03-09 13:21 1037Public Function ToExcel()On ... -
VB 建立快捷方式
2011-03-09 13:20 784Private Declare Function fCr ... -
VB 获取快捷方式原文件路径
2011-03-09 13:20 925'此方法不需要引用IShellLink.Private ... -
VB 的一组字符串转换函数
2011-03-09 13:20 788Public Function chrConvert(s ... -
VB 在浏览目录时指定初始目录
2011-03-09 13:19 1064'VB也可以使用CallBack,下面是一个例子: '先 ... -
VB 获得鼠标滚轮的事件
2011-03-09 13:18 999'窗体代码Private Sub Form_Load() ... -
VB 比较两组字符串
2011-03-09 13:18 1291【方法一】 StrComp(string1, Stri ... -
VB 用API下载文件实例
2011-03-09 13:17 803'########################### ... -
VB 窗口处理技巧大全
2011-03-09 13:17 788VB提供了API函数SetWindowLong和GetWind ... -
VB 实现屏幕右下角浮出式消息窗口,透明淡出效果。
2011-03-09 13:16 992'任务栏高度[此部分相关代码转载自 枕善居]Privat ... -
VB Filter 函数用法
2011-03-09 13:16 1958例子1:Dim aa(10) As StringDim bbD ... -
VB 在EXPLORER进程崩溃之后重建托盘图标
2011-03-09 13:15 852重点为:向系统注册“TaskbarCreated”消息 ... -
Shell 调用程序后等待该程序结束后返回继续
2011-03-09 13:15 1227方法1: Private Declare Functi ... -
VB 最简单的WAV声音或音乐文件播放的代码
2011-03-09 13:14 1376'最简单的WAV声音或音乐文件播放的代码'API声明Pr ...
相关推荐
在VB(Visual Basic)编程环境中,我们经常需要处理各种几何问题,其中之一就是根据已知的三个点的坐标来求解圆的中心。这个任务在实际应用中非常常见,例如在地图绘制、游戏开发或者数学计算软件中。下面将详细介绍...
在VB(Visual Basic)编程中,获取已知窗口句柄的EXE应用程序路径是一个常见的需求,这主要涉及到Windows API(应用程序接口)的调用和内存处理。窗口句柄(HWND)是Windows操作系统用来唯一标识一个窗口的对象句柄...
同时,为了便于使用,可以封装这些功能到一个函数或类中,以便在不同的项目中复用。 在提供的压缩包文件“前方交会”中,可能包含了上述VB代码的实现或者相关的说明文档,可以帮助进一步理解和应用这个算法。如果你...
假设我们有一个起点坐标(P0(x0, y0)),已知一个方位角θ(角度单位通常为度)和一个距离d,我们可以通过以下步骤计算目标点P1(x1, y1)的坐标: 1. 将角度θ转换为弧度。在VB中,可以使用`CDbl(Angle * (Math.PI / ...
是一个课件,主要讲了如何使用VB+SQL作一个信息管理系统
综上所述,VB获取另一个程序中SysListView32控件的内容是一个涉及进程间通信、控件识别和Win32 API调用的高级编程主题,需要对VB和Windows API有深入的理解。通过学习和实践这样的例子,开发者可以提高自己的编程...
使用VB.NET写的CHART控件使用例程,简单易懂.
在这个案例中,我们有一个名为“已知方位角距离求点坐标”的VB源代码,它专门用于计算导线点的坐标。 首先,我们需要理解几个基本概念: 1. 方位角:这是从正北方向到目标方向的角度,通常以度为单位。在0°至360°...
在本实例中,我们将探讨如何在Visual Basic 6.0(VB6.0)中利用`TreeView`控件来创建一个交互式的树状视图。下面我们将详细介绍`TreeView`控件的基本概念、属性、方法和事件,以及如何在VB6.0中编写源代码实现它的...
在“使用VB编程的方程式计算器”项目中,开发者利用VB6.0这一版本,构建了一个能够计算方程式的应用程序,让使用者无需复杂的数学知识,也能解决各类方程问题。 VB6.0是VB系列的一个经典版本,提供了丰富的控件库和...
vb6调用excel实例:共25行代码,vb6打开excel,vb6获取已经打开的excel,vb6编辑excel,vb6选择excel单元格,vb6获取excel的选择区域,vb6关闭excel
4. **循环解压每个文件**:对于ZIP文件中的每个数据块(代表一个或多个文件),使用Zlib的解压缩API进行解压,通常包括`inflateInit`、`inflate`和`inflateEnd`等函数。`inflateInit`初始化解压过程,`inflate`进行...
这个压缩包包含了核心的VB源代码,对于想要在VB中开发类似应用的人来说具有很高的参考价值。 人脸识别技术通常基于两种主要方法:特征提取和模板匹配。特征提取是通过算法提取人脸的关键特征,如眼睛、鼻子和嘴巴的...
`VB6.1编译的热键式窗口DLL效果演示.rar`文件是一个示例项目,展示了如何使用VB6.1来创建热键式窗口。热键,也称为快捷键,是通过按下特定组合的键来执行特定操作的方式,可以极大地提高用户的工作效率。这个示例...
在IT行业中,VB宏控件(Visual Basic for Applications Macro Controls)是Microsoft Office套件中一个强大的功能,它允许用户通过编程的方式来自动化和扩展Office应用程序的功能。这些控件使得用户不仅能够执行基本...
然后,我们可以在 Form1.vb 中添加一个按钮控件 Button1,并在点击事件中调用 CheckHidDevice() 函式来检查设备是否连接成功。如果连接成功,我们可以继续进行下一步操作。 在下一步中,我们可以使用 ReadUSB() 函...
这是一个VB6的IDE插件(Addin),使用VB6的IDE直接设计Python的界面。 Python和VB都是能让人快乐的编程语言,我使用了Python之后,很多自己使用的工具都使用Python开发或改写了,因为最终实现的Python代码实在太短了...
027、VB串口程序,,是一个串口使用例程,对初学者有用,特别是工控类的 028、VB串口传输文本,实现2台PC间的通信,类似简单的聊天工具 029、VB串口的一个电子称的项目 030、VB串口调试程序,用于通过串口控制松下空调测试 ...
这个主题探讨了如何利用PictureBox在VB.NET环境中实现图形绘制功能,为初学者提供了一个基础的起点。 首先,VB.NET提供了System.Drawing命名空间,该命名空间包含了许多类,如Graphics、Pen、Brush等,它们是进行...
在VB6.0中调用Web服务,特别是WebService,是一个重要的技术点,它允许传统的VB6应用程序利用基于网络的服务来扩展其功能。由于VB.NET的普及,很多开发者更倾向于使用.NET框架,但考虑到VB6的广泛使用和某些特定场景...