Click to See Complete Forum and Search --> : Help my pls one function


rusgrisli
November 18th, 2005, 03:46 AM
Im from Russia. Help my pls. My system XP SP2, Net, my right - Im Netadmin
Error code 50. Were is misteike

#pragma hdrstop

#include <windows.h>
#include <lmcons.h>
#include <lmserver.h>
#include <lmshare.h>
#include <lmerr.h>
#include <lmremutl.h>
#include <lmapibuf.h>
#include <lmmsg.h>
#include <lmrepl.h>
#include <lmat.h>
#include <lmstats.h>
#include <rassapi.h>
#include <iostream.h>


//-----------------------------------------------

const char *StrError(DWORD err)
{
static char retbuff[1024];

if (err == 0)
strcpy(retbuff, "\n");
else
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, retbuff, 1024, NULL);

if (strlen(retbuff) == 0)
strcpy(retbuff, "\n");


return retbuff;
}


DWORD DoNetStatisticsGet(LPWSTR RemoteName, LPWSTR ServiceName, DWORD Level )
{
NET_API_STATUS netapistatus;
LPBYTE ptb;

printf("NetStatisticsGet(%S) Level %u:\n", ServiceName, Level);

netapistatus = NetStatisticsGet(0, (wchar_t *)ServiceName, Level, 0, &ptb);
if (netapistatus != NERR_Success || ptb == NULL)
{
printf("Error %d getting statistics: %s", netapistatus, "" );
MessageBoxA(0, StrError(netapistatus), "Bad!!!", MB_OK);
} else {
if (wcscmp(ServiceName, L"SERVER") == 0)
{
STAT_SERVER_0 *pstatserver0 = (STAT_SERVER_0 *)ptb;

} else if (wcscmp(ServiceName, L"WORKSTATION") == 0) {
STAT_WORKSTATION_0 *pstatworkstation0 = (STAT_WORKSTATION_0 *)ptb;

}

puts("Not yet implemented");

NetApiBufferFree(ptb);
}

return netapistatus;
}

#pragma argsused
int main(int argc, char* argv[])
{
DoNetStatisticsGet(L"192.168.0.77", L"WORKSTATION", 0);
return 0;
}

Rezult Error code 50. Sir Help my pls.

NoHero
November 18th, 2005, 06:14 AM
Please use code tags next time when posting code. The code is better formated and thus easier to read!

NoHero
November 18th, 2005, 06:17 AM
For your error: Your error code 50 is ERROR_NOT_SUPPORTED, thus you are using some function/code parameter which is not supported. Have you dragged down the specific code line/function call causing the error?

rusgrisli
November 19th, 2005, 03:09 AM
Sie kome aus Austria? Ich wissen Anglish nicht gut. Jch denke dass Iher forum ist sehr gut. Ich habe keine gute firum in russland. Hilfen Sie mir bitte.
Ivan.

leojose
November 19th, 2005, 03:38 AM
Sie kome aus Austria? Ich wissen Anglish nicht gut. Jch denke dass Iher forum ist sehr gut. Ich habe keine gute firum in russland. Hilfen Sie mir bitte.
Ivan.
Rough Translation::rolleyes:
Is there any body from Austria?I do not know English very well.I think this forum is good.I do not have forum in Russia.I ask for assistance
Ivan

The documentation of the API NetStatisticsGet() says ...
Currently, only the workstation and server services are supported.
Does your system agree to this?

NoHero
November 19th, 2005, 05:33 AM
Sie kome aus Austria? Ich wissen Anglish nicht gut. Jch denke dass Iher forum ist sehr gut. Ich habe keine gute firum in russland. Hilfen Sie mir bitte.
Ivan.

Translation:
You are from Austria? I am not very good at English. I think this forum is quite good, but we don't have any programming forums in Russia, so please help me.

And please use the English language, so anyone here can understand you and is able to help you. Thank you.

rusgrisli
November 21st, 2005, 07:21 AM
My System Win XP SP2. Im have Admin right. This fragment code run and
screen out error code 50.

rusgrisli
November 21st, 2005, 07:24 AM
Function:

netapistatus = NetStatisticsGet(0, (wchar_t *)ServiceName, Level, 0, &ptb);
if (netapistatus != NERR_Success || ptb == NULL)

??????? Error 50

leojose
November 21st, 2005, 07:52 AM
My System Win XP SP2. Im have Admin right. This fragment code run and
screen out error code 50.
My understanding is that your System (XP-SP2) doesn't support this API. Try running it on Windows .NET Server 2003, Windows 2000 Server or Windows NT Server.