:1.在nt4.0下检测摩登是否在线?2.程序运行时最小化,但又不出现在任务栏内及桌面任何地方(50分)

  • 主题发起人 主题发起人 dqj
  • 开始时间 开始时间
D

dqj

Unregistered / Unconfirmed
GUEST, unregistred user!
1.下面的代码是网上摘的,用于检测摩登是否在线,我在nt4.0下使用总是显示"You have no active connections",麻烦邦我看一下代码须修改哪些地方.
2.在程序运行时最小化,但又不出现在任务栏内及桌面任何地方,csdn上有一些解答,我看不太懂,请给个完整的代码,最好有注释.
3.如果检测到摩登在线,同时又按下了"enter"键,则触发一个定时器,该怎样写代码?
附1.
Public Const ERROR_SUCCESS = 0&
Public Const APINULL = 0&
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public ReturnCode As Long

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal _
hKey As Long) As Long

Declare Function RegOpenKey Lib "advapi32.dll" Alias _
"RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As _
String, phkResult As Long) As Long

Declare Function RegQueryValueEx Lib "advapi32.dll" Alias _
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
As String, ByVal lpReserved As Long, lpType As Long, _
lpData As Any, lpcbData As Long) As Long

Public Function ActiveConnection() As Boolean
Dim hKey As Long
Dim lpSubKey As String
Dim phkResult As Long
Dim lpValueName As String
Dim lpReserved As Long
Dim lpType As Long
Dim lpData As Long
Dim lpcbData As Long
ActiveConnection = False
lpSubKey = "C:/WINNT/system32/ras/rasphone" '"System/CurrentControlSet/Services/RemoteAccess"
ReturnCode = RegOpenKey(HKEY_LOCAL_MACHINE, lpSubKey, _
phkResult)

If ReturnCode = ERROR_SUCCESS Then
hKey = phkResult
lpValueName = "Remote Connection"
lpReserved = APINULL
lpType = APINULL
lpData = APINULL
lpcbData = APINULL
ReturnCode = RegQueryValueEx(hKey, lpValueName, _
lpReserved, lpType, ByVal lpData, lpcbData)
lpcbData = Len(lpData)
ReturnCode = RegQueryValueEx(hKey, lpValueName, _
lpReserved, lpType, lpData, lpcbData)

If ReturnCode = ERROR_SUCCESS Then
If lpData = 0 Then
ActiveConnection = False
Else
ActiveConnection = True
End If
End If

RegCloseKey (hKey)
End If

End Function
Private Sub 在线_Click()
If ActiveConnection = True Then
Call MsgBox("You have an active connection.", vbInformation)
Else
Call MsgBox("You have no active connections.", vbInformation)
End If
End Sub

 
你这是VB的代码呀,VB的俺不会.
2,最小化但不出现在任何地方,什么意思?没搞明白.

SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);//不显示到任务栏
指定窗体最小值,然后启动时设为此值,不知是不是你要的效果.
 
最小化但不出现在任何地方,什么意思?
我说得不清楚.对不起.我想在程序运行时不出现在桌面和任务栏内.vb6.0,nt4.0
 
2 :
运行不出现: Form1->Hide() (bcb语法)
Form1.Hode() (delphi)

不出现在任务蓝:
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);
 
帮microbit更正一下:
是 form1.hide() ,:-)

"不出现在任务蓝:
SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);"
这也是delphi的语法吗?
 
接受答案了.
 
后退
顶部