Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:18:48+00:00 2026-05-25T12:18:48+00:00

I’, trying to create a service and change its configurations accourding to my needs.

  • 0

I’, trying to create a service and change its configurations accourding to my needs. creation is not a problem but when I want to change service settings it fails. I want to create Interactive service. here’s my code:

Public Function setInteractiveOption() As Boolean
    Dim hSCManager As Long
    Dim hService As Long
    hSCManager = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_ALL_ACCESS)

    hService = OpenService(hSCManager, SERVICE_NAME, SERVICE_CHANGE_CONFIG)

    Dim result As Long
    result = ChangeServiceConfig(hService, SERVICE_WIN32_OWN_PROCESS Or SERVICE_INTERACTIVE_PROCESS, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, vbNull, vbNull, vbNull, vbNull, vbNull, vbNull, vbNull)


    CloseServiceHandle hService

    If result Then
        setInteractiveOption = True
    Else
        setInteractiveOption = False
    End If

End Function

it gives me error code 1057 – The account name is invalid or does not exist, or the password is invalid for the account name specified.

Edit: here is my API delaration:

Public Declare Function ChangeServiceConfig Lib "advapi32.dll" Alias _
      "ChangeServiceConfigA" (ByVal hService As Long, ByVal dwServiceType _
      As Long, ByVal dwStartType As Long, ByVal dwErrorControl As Long, ByVal _
      lpBinaryPathName As String, ByVal lpLoadOrderGroup As String, lpdwTagId _
      As Long, ByVal lpDependencies As String, ByVal lpServiceStartName As String, _
      ByVal lpPassword As String, ByVal lpDisplayName As String) As Long

      Private Declare Function OpenService _
      Lib "advapi32" Alias "OpenServiceA" _
      (ByVal hSCManager As Long, ByVal lpServiceName As String, _
      ByVal dwDesiredAccess As Long) As Long  

      Private Declare Function OpenSCManager _
      Lib "advapi32" Alias "OpenSCManagerA" _
      (ByVal lpMachineName As String, ByVal lpDatabaseName As String, _
      ByVal dwDesiredAccess As Long) As Long

Public Const SERVICE_NO_CHANGE = &HFFFFM

You can download code of my project here(I downloaded orginal source from Internet):
http://www.mediafire.com/?138esmdw5tvt19q

I tested this program on XP (and failed) but in windows 7 it seems weird : I doesn’t register service but changing its configuration is successful!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:18:49+00:00Added an answer on May 25, 2026 at 12:18 pm

    If the error message is complaining about the account, then start there. You have the account parameters declared as string:

    ... ,ByVal lpServiceStartName As String, ByVal lpPassword As String
    

    so you will need to use vbNullString as the value to pass.

    Alternatively, redefine thjem as long:

    ..., ByVal lpServiceStartName As Long, ByVal lpPassword As Long
    

    and then pass 0& as the value.

    EDIT1:

    I changed

    Public Const SERVICE_NO_CHANGE = &HFFFF 
    

    to

    Public Const SERVICE_NO_CHANGE = &HFFFFFFFF 
    

    and, referencing my own service that was already installed, I called setInteractiveOption and it was successful on XP Pro. I made sure that the account of the service is setup as LocalSystem, as indicated in the MSDN.

    EDIT2:

    Here is the decalre (you must also use the constant from EDIT1)

    Public Declare Function ChangeServiceConfig Lib "advapi32.dll" _
    Alias "ChangeServiceConfigA" ( _
       ByVal hService As Long, _
       ByVal dwServiceType As Long, _
       ByVal dwStartType As Long, _
       ByVal dwErrorControl As Long, _
       ByVal lpBinaryPathName As String, _
       ByVal lpLoadOrderGroup As String, _
       ByVal lpdwTagId As String, _
       ByVal lpDependencies As String, _
       ByVal lpServiceStartName As String, _
       ByVal lpPassword As String, _
       ByVal lpDisplayName As String) As Long
    

    Here is your method:

    Public Function setInteractiveOption() As Boolean
        Dim hSCManager As Long
        Dim hService As Long
        hSCManager = OpenSCManager(vbNullString, vbNullString, SC_MANAGER_ALL_ACCESS)
        MsgBox "hSCManager: " & hSCManager
        hService = OpenService(hSCManager, SERVICE_NAME, SERVICE_CHANGE_CONFIG)
        MsgBox "hService: " & hService
        Dim result As Long
    
        result = ChangeServiceConfig(hService, _
                                     SERVICE_WIN32_OWN_PROCESS Or SERVICE_INTERACTIVE_PROCESS, _
                                     SERVICE_NO_CHANGE, _
                                     SERVICE_NO_CHANGE, _
                                     vbNullString, _
                                     vbNullString, _
                                     vbNullString, _
                                     vbNullString, _
                                     vbNullString, _
                                     vbNullString, _
                                     vbNullString)
    
        MsgBox "result: " & result & vbNewLine & "Error: " & Err.LastDllError
    
        CloseServiceHandle hService
    
        If result Then
            setInteractiveOption = True
        Else
            setInteractiveOption = False
        End If
    
    End Function
    

    I then added a button to call just this method to your form and it worked great.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.