-
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
-
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 :eek:
-
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
-
format_message_from_system?
-
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
-
i think i need to use SERVICE_WIN32_OWN_PROCESS ... but i cant find it ... any ideas?
-
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)
-
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
-
where did you get the constants from?? i couldnt find them in api viewer