VB中一些API的使用
来源:互联网 发布:汉服淘宝店推荐知乎 编辑:程序博客网 时间:2024/06/05 00:42
Public Declare Sub Sleep()Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Declare Function GetTickCount()Function GetTickCount Lib "kernel32" () As Long
Private Declare Function OpenProcess()Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject()Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle()Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess()Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess()Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetForegroundWindow()Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function IsWindow()Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Sub Waitms()Sub Waitms(ms As Long)
Dim t1 As Long
Dim t2 As Long
t1 = GetTickCount
Do
DoEvents
Sleep 200
t2 = GetTickCount
Loop While t2 - t1 < ms
End Sub
Public Function ShellWait()Function ShellWait(cmd As String) As Long
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ALIVE = &H103
Const INFINITE = &HFFFF
Dim ExitCode As Long
Dim hProcess As Long
Dim pid As Long
pid = Shell(cmd, vbHide)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While ExitCode = STILL_ALIVE
Call CloseHandle(hProcess)
ShellWait = ExitCode
End Function
Public Declare Function GetTickCount()Function GetTickCount Lib "kernel32" () As Long
Private Declare Function OpenProcess()Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject()Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle()Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess()Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess()Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function GetForegroundWindow()Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function IsWindow()Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Sub Waitms()Sub Waitms(ms As Long)
Dim t1 As Long
Dim t2 As Long
t1 = GetTickCount
Do
DoEvents
Sleep 200
t2 = GetTickCount
Loop While t2 - t1 < ms
End Sub
Public Function ShellWait()Function ShellWait(cmd As String) As Long
Const PROCESS_QUERY_INFORMATION = &H400
Const STILL_ALIVE = &H103
Const INFINITE = &HFFFF
Dim ExitCode As Long
Dim hProcess As Long
Dim pid As Long
pid = Shell(cmd, vbHide)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While ExitCode = STILL_ALIVE
Call CloseHandle(hProcess)
ShellWait = ExitCode
End Function
'フォルダ設定用構造体
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'ファイルシステム利用できる
Public Const BIF_RETURNONLYFSDIRS = &H1
'Api関数
Public Declare Function SHGetPathFromIDList()Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Public Declare Function SHBrowseForFolder()Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Dim bi As BROWSEINFO
bi.hOwner = Me.hWnd
bi.pidlRoot = 0&
bi.lpszTitle = "VHDLフォルダご指定ください"
bi.ulFlags = BIF_RETURNONLYFSDIRS
pidl = SHBrowseForFolder(bi)
path = Space$(512)
r = SHGetPathFromIDList(ByVal pidl&, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
txtPath1.Text = Left(path, pos - 1)
Else
txtPath1.Text = ""
End If
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'ファイルシステム利用できる
Public Const BIF_RETURNONLYFSDIRS = &H1
'Api関数
Public Declare Function SHGetPathFromIDList()Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Public Declare Function SHBrowseForFolder()Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Dim bi As BROWSEINFO
bi.hOwner = Me.hWnd
bi.pidlRoot = 0&
bi.lpszTitle = "VHDLフォルダご指定ください"
bi.ulFlags = BIF_RETURNONLYFSDIRS
pidl = SHBrowseForFolder(bi)
path = Space$(512)
r = SHGetPathFromIDList(ByVal pidl&, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
txtPath1.Text = Left(path, pos - 1)
Else
txtPath1.Text = ""
End If
- VB中一些API的使用
- GCD中一些API的使用
- VB使用API的例子
- vb.net中serialport控件的一些使用经验
- vb.net中serialport控件的一些使用经验
- vb.net中serialport控件的一些使用经验 .
- 在VB中使用API关闭窗口
- 在 VB 中使用 Unicode API
- 使用API在VB中创建状态栏
- VB中使用API操作注册表
- 如何在VB中使用导入API
- 在VB中使用API关闭窗口
- 在 VB 中使用 Unicode API
- 在VB中使用API关闭窗口
- 在 VB 中使用 Unicode API
- 如何在VB中使用API函数
- 一些API的使用
- VB中调用Windows API的注意事项
- 控制反转(Ioc)
- 菜鸟安装NetBPM记录
- Ruby On Rails学习笔记(4)——为first增加视图
- 我的第一篇文章——Kruskal算法用C语言的实现!
- 全面认识UML类图元素
- VB中一些API的使用
- 菜菜日志之菜菜写文章
- RIA三剑客大比拼
- 不要重复编写DAO
- UNIX基础知识
- Linux操作系统主机名(hostname)简说
- 养儿子是建设银行,女儿是招商银行
- GWT笔记1
- stdafx.h是什么用处?