Results 1 to 9 of 9

Thread: what is wrong??

  1. #1

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179

    what is wrong??

    Public Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long

    Public Function LastSystemError() As String

    Const FORMAT_MESSAGE_FORM_SYSTEM = &H1000

    Dim sError As String * 500
    Dim lErrMsg As Long

    lErrMsg = FormatMessage(format_message_from_system, ByVal 0&, Err.LastDllError, sError, Len(sError), 0) 'I'm sure there is something missing

    LastSystemError = Trim$(sError)

    End Function
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Code:
    lErrMsg = FormatMessage(format_message_from_system, ByVal 0&, Err.LastDllError, sError, Len(sError), 0) 'I'm sure there is
    you misspelled your constant (first parameter)


    post back quick cause you're on 69 posts
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    heres an example from allapi:
    Code:
    'Create a new project and add this code to Form1
    Const FORMAT_MESSAGE_ALLOCATE_BUFFER = &H100
    Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
    Const LANG_NEUTRAL = &H0
    Const SUBLANG_DEFAULT = &H1
    Const ERROR_BAD_USERNAME = 2202&
    Private Declare Function GetLastError Lib "kernel32" () As Long
    Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)
    Private Declare Function FormatMessage Lib "kernel32" Alias "FormatMessageA" (ByVal dwFlags As Long, lpSource As Any, ByVal dwMessageId As Long, ByVal dwLanguageId As Long, ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Long) As Long
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim Buffer As String
        'Create a string buffer
        Buffer = Space(200)
        'Set the error number
        SetLastError ERROR_BAD_USERNAME
        'Format the message string
        FormatMessage FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, GetLastError, LANG_NEUTRAL, Buffer, 200, ByVal 0&
        'Show the message
        MsgBox Buffer
    End Sub
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    format_message_from_system?
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  5. #5
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Const FORMAT_MESSAGE_FORM_SYSTEM = &H1000

    doesn't match with:

    lErrMsg = FormatMessage(format_message_from_system, ByVal 0&, Err.LastDllError, sError, Len(sError), 0) 'I'm sure there is
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  6. #6

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    i think i need to use SERVICE_WIN32_OWN_PROCESS ... but i cant find it ... any ideas?
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  7. #7

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    this is what i have so far, although the account exists, it is telling me that the account is invalid

    iOpenService = OpenService(iOpenScManagerResult, srServiceName, SERVICE_ALL_ACCESS)

    iLock = LockServiceDatabase(iOpenService)

    iChangeServiceConfigResult = ChangeServiceConfig(iOpenService, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, vbNullString, vbNullString, 0&, vbNullString, "ccnt\servicetvd" & vbNullChar, "Laser100" & vbNullChar, sServiceName)

    iUnlock = UnlockServiceDatabase(temp)
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  8. #8
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    ere you go boy these might come in useful...
    Code:
          Public Const ERROR_MORE_DATA = 234
          Public Const SERVICE_ACTIVE = &H1
          Public Const SERVICE_INACTIVE = &H2
          Public Const SC_MANAGER_ENUMERATE_SERVICE = &H4
          Public Const SERVICE_WIN32_OWN_PROCESS As Long = &H10
          Public Const SERVICE_WIN32_SHARE_PROCESS As Long = &H20
          Public Const SERVICE_WIN32 As Long = SERVICE_WIN32_OWN_PROCESS _
                      + SERVICE_WIN32_SHARE_PROCESS
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  9. #9

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    where did you get the constants from?? i couldnt find them in api viewer
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

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