我需要以下代码的VB 6版本... [英] I require the VB 6 version of the below code...

查看:71
本文介绍了我需要以下代码的VB 6版本...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public Class WorkStationReader
#Region "API Calls"
 rivate Const DESKTOP_CREATEMENU As Int32 = &H4&
Private Const DESKTOP_CREATEWINDOW As Int32 = &H2&
Private Const DESKTOP_ENUMERATE As Int32 = &H40&
Private Const DESKTOP_HOOKCONTROL As Int32 = &H8&
Private Const DESKTOP_READOBJECTS As Int32 = &H1&
Private Const DESKTOP_SWITCHDESKTOP As Int32 = &H100&
Private Const DESKTOP_WRITEOBJECTS As Int32 = &H80&
Private Const GENERIC_WRITE As Int32 = &H40000000
Private Const HWND_BROADCAST As Int32 = &HFFFF&
Private Const WM_HOTKEY As Int32 = &H312
Private Const MOD_ALT As Int32 = &H1
Private Const MOD_CONTROL As Int32 = &H2
Private Const VK_DELETE As Int32 = &H2E
Private Const UOI_NAME As Int32 = 2
Private Declare Function OpenDesktop Lib "user32" Alias "OpenDesktopA" (ByVal lpszDesktop As String, ByVal dwFlags As Int32, ByVal fInherit As Boolean, ByVal dwDesiredAccess As Int32) As Int32
Private Declare Function CloseDesktop Lib "user32" (ByVal hDesktop As Int32) As Int32
Private Declare Function SwitchDesktop Lib "user32" (ByVal hDesktop As Int32) As Int32
#End Region
#Region "WorkStationReader Global Variables"
 im p_lngHwnd As Int32
Dim p_lngRtn As Int32
Dim p_lngErr As Int32
Dim l_lkwkst As Int32
#End Region
#Region "WorkStationReader Events"
 vent locked(ByVal ivarreturn As Object)
#End Region
#Region "WorkStationReader Functions"
 unction WorkStationISLocked() As Object
Dim ivarreturn(2) As Object
p_lngHwnd = OpenDesktop("Default", 0, False, DESKTOP_SWITCHDESKTOP)
If p_lngHwnd = 0 Then
ivarreturn(0) = "Error with OpenDesktop: " & Err.LastDllError
ivarreturn(1) = False
WorkStationISLocked = ivarreturn
RaiseEvent locked(ivarreturn)
Exit Function
Else
p_lngRtn = SwitchDesktop(hDesktop:=p_lngHwnd)
p_lngErr = Err.LastDllError
If p_lngRtn = 0 Then
If p_lngErr = 0 Then
'ivarreturn(0) = "Desktop is locked: " & Err.LastDllError
ivarreturn(0) = "Locked : " '& Err.LastDllError
ivarreturn(1) = True
WorkStationISLocked = ivarreturn
RaiseEvent locked(ivarreturn)
GoTo CleanUpProc
Else
ivarreturn(0) = "Error with SwitchDesktop: " & Err.LastDllError
ivarreturn(1) = False
WorkStationISLocked = ivarreturn
GoTo CleanUpProc
End If
Else
'ivarreturn(0) = "Not locked!"
ivarreturn(0) = "Unlocked : "
ivarreturn(1) = False
WorkStationISLocked = ivarreturn
RaiseEvent locked(ivarreturn)
GoTo CleanUpProc
End If
End If
Exit Function
CleanUpProc:
p_lngHwnd = CloseDesktop(p_lngHwnd)
End Function
#End Region
End Class

推荐答案

三个API调用-OpenDesktopCloseDesktopSwitchDesktop-都有详细的文档记录,并且在网络上有大量信息.我希望这些API上的信息具有与您尝试执行的代码非常相似的代码.
The three API calls -- OpenDesktop, CloseDesktop and SwitchDesktop -- are well documented, with plenty of information on the web. I would expect that information on these APIs would have code very similar to what you are trying to do.


您是否要将vb.net转换为VB6代码?你尝试了什么?为什么您认为有人会为您做这项工作?
Are you asking to convert vb.net to VB6 code? What have you tried? why do you think some one will do the job for you?


这篇关于我需要以下代码的VB 6版本...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆