PDA

Click to See Complete Forum and Search --> : HELP::API(findwindow)+ASP does not work?


chun zhang
May 2nd, 2000, 10:28 PM
I use VB write a ACTIVEX DLL like this:
/*********************************************************/
' Declare necessary API routines:
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any) As Long

Private Declare Function PostMessage Lib "user32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Function LampOn() As Integer
Dim hWndSerialControl As Long
Dim a As Long


Dim fso, txtfile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtfile = fso.CreateTextFile("c:\testfile.txt", True)
txtfile.Write ("This is a test. ") ' Write a line.
' Write a line with a newline character.
txtfile.WriteLine ("Testing 1, 2, 3.")
' Write three newline characters to the file.
txtfile.WriteBlankLines (3)
txtfile.Close


hWndSerialControl = FindWindow(vbNullString, "serialcontrol")
If hWndSerialControl <> 0 Then
a = PostMessage(hWndSerialControl, 1124, 1, 0)
LampOn = 0
Else
LampOn = 1
End If
End Function
Public Function LampOff() As Integer
Dim hWndSerialControl As Long
Dim a As Long
hWndSerialControl = FindWindow(vbNullString, "serialcontrol")
If hWndSerialControl <> 0 Then
a = PostMessage(hWndSerialControl, 1124, 2, 0)
LampOff = 0
Else
LampOff = 1
End If
End Function
Public Function LampBlink(Frequency As Integer) As Integer
Dim hWndSerialControl As Long
Dim a As Long
hWndSerialControl = FindWindow(vbNullString, "serialcontrol")
If hWndSerialControl <> 0 Then
a = PostMessage(hWndSerialControl, 1124, 3, Frequency)
LampBlink = 0
Else
LampBlink = 1
End If
End Function
/*********************************************************/

I test it using standard exe like this:
Result is as expected.
/*********************************************************/
Private Sub Command1_Click()
Dim x As New mylamp.Operation
a = x.LampOn()
End Sub
/*********************************************************/

PROBLEM is :
when I use it under ASP like this:
IT NEVER WORK!!! HELP ME. GREATE THANKS.
/*********************************************************/
<%
Set x = server.CreateObject("mylamp.Operation")
a = x.LampOn
b = 0
%>
/*********************************************************/

lychew
May 3rd, 2000, 09:00 AM
I tried your code and it works??
Have you compile your activex into dll or register the dll in the machine you are using??

chun zhang
May 3rd, 2000, 10:58 AM
Originally posted by lychew
I tried your code and it works??
Have you compile your activex into dll or register the dll in the machine you are using??

Hi, there

I have also test it in another machine[win98].
And this time, it does work!!!
But the one under windows NT workstation 4.0
really does not work!!!

Security reason? Or ???