|
-
Jun 19th, 2001, 02:59 AM
#1
Thread Starter
Addicted Member
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
-
Jun 19th, 2001, 03:07 AM
#2
Fanatic Member
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]
-
Jun 19th, 2001, 03:08 AM
#3
Fanatic Member
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]
-
Jun 19th, 2001, 03:09 AM
#4
Thread Starter
Addicted Member
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
-
Jun 19th, 2001, 03:12 AM
#5
Fanatic Member
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]
-
Jun 21st, 2001, 04:08 AM
#6
Thread Starter
Addicted Member
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
-
Jun 21st, 2001, 04:24 AM
#7
Thread Starter
Addicted Member
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
-
Jun 21st, 2001, 05:00 AM
#8
Fanatic Member
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]
-
Jun 21st, 2001, 05:02 AM
#9
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|