Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EnumServicesStatusEx rc=1783 Windows2003

255 views
Skip to first unread message

Alan Rotnemer

unread,
Aug 2, 2003, 8:40:29 AM8/2/03
to
Our application calls Windows apis to get information on
Services. It worked OK on Windows 2000. On a Windows2003
(.Net) system it fails on a call to EnumServicesStatusEx()
or EnumServicesStatus() with a Return code of 1783 (from
GetLastError(). FormatMessage() displays "The Stub
Received Bad Data". This error condition is not found in
the documentation. Below is a snippet of sample code. Has
anyone seen this, and if yes, could an explanation be
provided? Thanks.

int main(int argc, char *argv[])
{

#define SZ_ENUM_BUF 4096

ENUM_SERVICE_STATUS_PROCESS essServiceStatus
SZ_ENUM_BUF];
DWORD dwBufSize =
sizeof(essServiceStatus);
DWORD dwBytesNeeded =
0;
DWORD dwServicesReturned =
0;
DWORD dwResumeHandle =
0;
DWORD dwIndex =
0;

SC_HANDLE hSCManager =
NULL;

hSCManager= OpenSCManager(NULL,
NULL,SC_MANAGER_ALL_ACCESS);
if (hSCManager == NULL)
{
// failure
printf("OpenSCManager error code %d\n",GetLastError
());
printf("Program completion\n");
return 0;
}

if (!EnumServicesStatusEx(hSCManager,
SC_ENUM_PROCESS_INFO,
SERVICE_WIN32,
SERVICE_STATE_ALL,
(LPBYTE)essServiceStatus,
dwBufSize,
&dwBytesNeeded,
&dwServicesReturned,
&dwResumeHandle,
NULL))
{
// failure
printf("EnumServicesStatusEx error code %
d\n",GetLastError());
}
printf("Program completion\n");
CloseHandle(hSCManager);
return 0;

}

Alan

unread,
Aug 11, 2003, 4:27:47 PM8/11/03
to
Got an email response to this that ended up doing the
trick.

The code was changed to call EnumServicesStatus() twice,
first to get the length of the buffer that gets allocated
and used in the second call. The first call gets an
ERROR_MORE_DATA error code with pcbBytesNeeded being the
returned needed buffer size.

To the sender of this - thank you.

>.
>

0 new messages