通过vb6 app

时间:2015-12-28 11:05:49

标签: .net vb6

我制作了一个Windows服务应用程序“Windows服务”

之后我创建了一个Config屏幕,它是类库“.dll”

通过Config界面,我可以/安装/卸载/启动/停止我的服务。

使用.net确保一切正常。

当我从vb6应用程序引用并调用.dll时,它不会安装服务。 对于安装,我使用标准代码

   If sUser = Nothing Then
            Dim hSvc As Integer = CreateService(hSCM, ServiceName, DisplayName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, PathService, Nothing, Nothing, Nothing, Nothing, Nothing)

            If hSvc = 0 Then
                CloseServiceHandle(hSvc)
                Exit Sub
            End If

            CloseServiceHandle(hSvc)
            CloseServiceHandle(hSCM)

        Else
            Dim hSvc As Integer
            Try
                hSvc = CreateService(hSCM, ServiceName, DisplayName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, PathService, Nothing, Nothing, Nothing, sUser, sPassword)
            Catch ex As Exception

            End Try


            If hSvc = 0 Then
                CloseServiceHandle(hSvc)
                Exit Sub
            End If

            CloseServiceHandle(hSvc)
            CloseServiceHandle(hSCM)

        End If

0 个答案:

没有答案