- 浏览: 174850 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
xiangyufangai:
很好很强大膜拜中哈哈!!
VB 两个字符串处理函数(类似Left/Mid/Right/Split的结合) -
hellohank:
这个……叫摘要算法,不叫加密算法~
Java实现的加密工具类(支持MD5和SHA) -
NIUCH1029291561:
接口有问题奥
网银在线支付接口和应用 -
yeuego:
能幫你就行了
MySQL索引分析 -
ForgiDaved:
很给力的介绍。记得前段时间给一个系统加功能,设计的表没有 ...
MySQL索引分析
Option Explicit
Private Declare Function CreatePipe _
Lib "kernel32" (phReadPipe As Long, _
phWritePipe As Long, _
lpPipeAttributes As SECURITY_ATTRIBUTES, _
ByVal nSize As Long) As Long
Private Declare Function CreateProcess _
Lib "kernel32" _
Alias "CreateProcessA" (ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
lpProcessAttributes As SECURITY_ATTRIBUTES, _
lpThreadAttributes As SECURITY_ATTRIBUTES, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
lpEnvironment As Any, _
ByVal lpCurrentDriectory As String, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function TerminateProcess _
Lib "kernel32" (ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Declare Function ReadFile _
Lib "kernel32" (ByVal hFile As Long, _
ByVal lpBuffer As String, _
ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, _
lpOverlapped As Any) As Long
Private Declare Function WriteFile _
Lib "kernel32" (ByVal hFile As Long, _
ByVal lpBuffer As String, _
ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, _
lpOverlapped As Any) As Long
Private Declare Function GetFileSize _
Lib "kernel32" (ByVal hFile As Long, _
lpFileSizeHigh As Long) As Long
Private Declare Function CloseHandle _
Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetLastError _
Lib "kernel32" () As Long
Private Declare Sub CopyMemory _
Lib "kernel32" _
Alias "RtlMoveMemory" (ByVal Destination As String, _
ByVal Source As String, _
ByVal Length As Long)
Private Declare Function lstrLen _
Lib "kernel32" _
Alias "lstrlenA" (ByVal lpString As String) As Long
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Const STARTF_USESTDHANDLES = &H100
Private Const STARTF_USESHOWWINDOW = &H1
Private Const NORMAL_PRIORITY_CLASS = &H20
Dim hReadPipe As Long
Dim hWritePipe As Long
Dim hReadFile As Long
Dim hWriteFile As Long
Dim pi As PROCESS_INFORMATION
Private Const Pipe_Max_Length As Long = 65536 '64K的空间
Public Function CreateProcessWithPipe(Optional ByVal FileName As String = "cmd.exe") As Boolean
On Error GoTo ErrHdl
Dim ret&
Dim sa As SECURITY_ATTRIBUTES
With sa
.nLength = Len(sa)
'.bInheritHandle = False
.bInheritHandle = True
.lpSecurityDescriptor = 0
End With
'create two pipe->one for input & output and another for err handle
ret = CreatePipe(hReadPipe, hWriteFile, sa, Pipe_Max_Length): If ret = 0 Then Call RaiseErr
ret = CreatePipe(hReadFile, hWritePipe, sa, Pipe_Max_Length): If ret = 0 Then Call RaiseErr
'since now , we had create two pipes.
Dim si As STARTUPINFO
'fill start info
With si
.cb = Len(si)
.hStdInput = hReadPipe
.hStdOutput = hWritePipe
.hStdError = hWritePipe
'in fact. both error msg and normal msg r msg, so we can let then in a same handle
.wShowWindow = 0 'hide it
.dwFlags = STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW 'use handles, to make our hstd*** avable. use showwindow, to make our wShowWindow setting avable
End With
'createprocess----normally,it should be cmd.
ret = CreateProcess(vbNullString, FileName, sa, sa, True, NORMAL_PRIORITY_CLASS, 0&, App.Path, si, pi): If ret = 0 Then Call RaiseErr
CreateProcessWithPipe = True
Exit Function
ErrHdl:
Call TerminateProcessAndClosePipe
CreateProcessWithPipe = False
End Function
Public Function GetStringFromPipe() As String
On Error GoTo ErrHdl
Dim ret&
Dim sBuffer As String
Dim lRead As Long
Dim sReturn As String
sBuffer = Space$(Pipe_Max_Length)
ret = ReadFile(hReadFile, sBuffer, Len(sBuffer), lRead, ByVal 0&) 'lRead is bytes that had read actully
sReturn = Space$(lRead)
CopyMemory sReturn, sBuffer, lRead
GetStringFromPipe = sReturn
Exit Function
ErrHdl:
GetStringFromPipe = ""
End Function
Public Function PipeIsNull() As Boolean
PipeIsNull = (GetFileSize(hReadFile, 0&) <= 0)
End Function
Public Function PutStringToPipe(ByVal StrToPut As String) As Boolean
On Error GoTo ErrHdl
'most of time, u need to append a vbCrLf after the string u want to put.
Dim ret&
Dim lWrittenBytes As Long
ret = WriteFile(hWriteFile, StrToPut, lstrLen(StrToPut), lWrittenBytes, ByVal 0&): If ret = 0 Then Call RaiseErr
PutStringToPipe = (lWrittenBytes = Len(StrToPut))
Debug.Print hWriteFile
Exit Function
ErrHdl:
PutStringToPipe = False
End Function
Public Function TerminateProcessAndClosePipe() As Boolean
On Error GoTo ErrHdl
Dim ret&
ret = TerminateProcess(pi.hProcess, 0): If ret = 0 Then Call RaiseErr
ret = CloseHandle(hReadPipe): If ret = 0 Then Call RaiseErr
ret = CloseHandle(hReadFile): If ret = 0 Then Call RaiseErr
ret = CloseHandle(hWritePipe): If ret = 0 Then Call RaiseErr
ret = CloseHandle(hWriteFile): If ret = 0 Then Call RaiseErr
TerminateProcessAndClosePipe = True
Exit Function
ErrHdl:
TerminateProcessAndClosePipe = False
End Function
Private Sub RaiseErr()
On Error Resume Next
Err.Raise vbObjectError + 1 'raise an error so that to be caught by errhdl
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 1116Option 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 1066'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 1377'最简单的WAV声音或音乐文件播放的代码'API声明Pr ...
相关推荐
vb 常用icon图标,个性化自己的程序必备
【标题】"VB6企业版光盘1:桌面开发的基石" Visual Basic 6(VB6)是微软在1998年推出的一款强大的可视化编程环境,尤其适用于桌面应用程序的开发。"sc_vb6_ent_cd1.zip" 是VB6企业版的压缩包文件,其中包含的是第...
标题中的“VB.rar_ACRptEngineX.o_VB 表格_acrptenginex.ocx_ocx vb_vb 报表”表明这是一个与Visual Basic(VB)编程相关的压缩包,其中包含一个名为ACRptEngineX.ocx的ActiveX控件,用于处理报表展示。ActiveX控件...
标签中的"ezvidcap._o vb_ocx vb_摄像头 ezvidcap.o vb__ocx"进一步强调了这是与VB开发摄像头应用有关的OCX控件,ezvidcap可能是控件的类名或库名。 压缩包内的文件列表: 1. `register.bat`:注册批处理文件,...
标题中的“vbpcap_sniff.rar_ vbpc_VBPCAP_Winpcap sniff vb_vb WinPcap_vb wi”表明这是一个与VB(Visual Basic)编程语言相关的项目,使用了WinPcap库来实现网络数据包捕获,即网络嗅探功能。WinPcap是一个在...
在IT行业中,VB(Visual Basic)与MATLAB的联合编程是一种常见的技术,它允许开发者利用MATLAB的强大计算能力,同时利用VB的用户界面设计和系统集成能力。本示例是关于如何通过VB调用MATLAB的COM接口进行交互的一个...
【标题】"VB6_CHM_simple.zip_vb6" 是一个与Visual Basic 6相关的压缩文件,其中包含了一些关于Visual Basic 6编程的CHM( Compiled Help Manual)格式的文档。CHM文件是微软开发的帮助文件系统,它将HTML文档集合在...
【标题】"vb.netQQ.rar_ vb.netQQ_QQ Vb.NET_VB .net_VB.NET ICQ_vb.net" 涉及的核心知识点主要集中在使用VB.NET编程语言开发一个QQ客户端的源代码程序。VB.NET是Visual Basic .NET的简称,是微软公司推出的一种面向...
【标题】"wxh vb_project.zip" 暗示我们关注的是一个VB(Visual Basic)项目,这个项目可能是一个软件应用程序或系统,被压缩在名为"vb_project.zip"的文件中。VB是一种由Microsoft开发的事件驱动编程语言,主要用于...
【标题】"sedwen_cwqe_VB源码_源码.zip" 提供的是一份VB(Visual Basic)编程语言的源代码集合。VB是一种基于Windows环境的事件驱动编程工具,由微软公司开发,它以其易学易用、强大的图形用户界面设计功能而闻名。 ...
"VB_window.rar_vb window.restore_vb 界面_vb界面"这个标题暗示了我们将在VB环境中讨论如何处理窗口状态,特别是窗口的恢复操作以及创建和设计用户界面。 1. **VB窗口状态管理**:在VB中,窗口有多种状态,包括...
标题中的"VB_Test.rar_VB Winpp_VB_test_barcode vb_vb 条码_条码打印机"揭示了这个压缩包文件与Visual Basic(VB)编程语言相关,特别是关于条码打印的应用。VB Winpp可能是指一个特定的VB库或者模块,用于Windows...
VB6-Sirk Mini 安装版 最新版 包含插件 增强版 包含 Addins
1. **XMLDOMDocument.cls** - 这可能是一个名为XMLDOMDocument的类文件,它是VB类库的核心,用于封装MSXML中的DOM(文档对象模型)接口,允许开发者通过对象方法和属性来操作XML文档。 2. **工程1.exe** - 这是编译...
VB代码与WebBrowser控制中的HTML代码,互相控制的例子。 点VB中的按钮,改变网页的显示样式...点网页中的按钮,修改VB中控件的属性,或调用VB中的函数。这只是一个如何实现的示例,没有什么强大功能,代码有中文说明。
用VB调用S7_200_PPI这个动态链接库与PLC200通讯
【标签】中的"vb网页 vb_百度翻译 www._baidufanyi.com 百度翻译 翻译" 是对该程序特性的关键词标注,其中: - "vb网页" 表明是使用VB(Visual Basic)开发的Web相关应用。 - "vb_百度翻译" 指出这个VB程序与百度...
标题中的"VB_XML.rar_ VB_XML_VB speeaksdk xml_vb xml_xml_xml vb"表明这个压缩包包含了与Visual Basic(VB)编程语言和XML处理相关的代码示例。XML,全称Extensible Markup Language,是一种用于存储和传输数据的...
1. **IISBACK.VB_**:这个文件名暗示可能是一个备份相关的VB(Visual Basic)脚本。它可能用于备份IIS的配置或网站数据,确保在系统故障或更新后能够恢复。 2. **IISEXT.VB_**:这可能涉及到IIS的扩展功能,可能是...
标题中的"VB_automatically_fill_form_submit_single.rar_.submit vb_Single a"表明这是一个关于使用Visual Basic(VB)编程语言实现自动填充表单并提交的示例代码。在这个实例中,我们将探讨如何利用VB来自动化网页...