partitionist
Erfahrenes Mitglied
wollte von microsoft ein beispiel testen, aber dann hab ich ein fehler bekommen:
error C2664: 'NetSessionGetInfo' : Konvertierung des Parameters 1 von 'unsigned short *' in 'char *' nicht moeglich
Die Typen, auf die verwiesen wird, sind nicht verwandt; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat
Code:
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <windows.h>
#include <lm.h>
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 10;
LPSESSION_INFO_10 pBuf = NULL;
LPTSTR pszServerName = NULL;
LPTSTR pszUNCClientName = NULL;
LPTSTR pszUserName = NULL;
NET_API_STATUS nStatus;
//
// Check command line arguments.
//
if (argc == 3)
{
pszUNCClientName = argv[1];
pszUserName = argv[2];
}
else if (argc == 4)
{
pszServerName = argv[1];
pszUNCClientName = argv[2];
pszUserName = argv[3];
}
else
{
wprintf(L"Usage: %s [\\\\ServerName] \\\\ClientName UserName\n", argv[0]);
exit(1);
}
//
// Call the NetSessionGetInfo function, specifying level 10.
//
nStatus = NetSessionGetInfo(pszServerName, // ! HIER LIEGT DER FEHLER!!
pszUNCClientName,
pszUserName,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
//
// Print the session information.
//
wprintf(L"\n\tClient: %s\n", pBuf->sesi10_cname);
wprintf(L"\tUser: %s\n", pBuf->sesi10_username);
printf("\tActive: %d\n", pBuf->sesi10_time);
printf("\tIdle: %d\n", pBuf->sesi10_idle_time);
}
}
//
// Otherwise, indicate a system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return 0;
}