Results 1 to 3 of 3

Thread: HELP::API(findwindow)+ASP does not work?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    2

    Angry

    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
    %>
    /*********************************************************/



    jasonusa

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    I tried your code and it works??
    Have you compile your activex into dll or register the dll in the machine you are using??

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    2

    Question

    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 ???
    jasonusa

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width