Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Product Lifecycle
  3. Collaboration / Beta Testing
  4. Serious:Client Server User Tracking

Serious:Client Server User Tracking

Scheduled Pinned Locked Moved Collaboration / Beta Testing
c++sysadmindebugginghelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brilliant101
    wrote on last edited by
    #1

    I am building a client server user tracking system that will get the username and computer name from the client kernel and send it to server via winsock. I have got the different pieces of the puzzle but now i want to combine them all. So help me out 1) i have the perfect running code of the system call GetComputerName( ). which uses windows.h #include #include int WINAPI WinMain(HINSTANCE h,HINSTANCE p,LPSTR c,int n) { TCHAR szName[256]; // pointer to system information string TCHAR szBuffer[512]; // buffer for expanded string unsigned long iTextLength; TCHAR szSystemInfo[5]; iTextLength = sizeof(szName)/sizeof(TCHAR); // number of characters, not bytes GetComputerName(szName, &iTextLength); iTextLength = sprintf(szBuffer, "Computer name: %s", szName); MessageBox(0, szBuffer, "Computer Name", 0); GetUserName(szName,&iTextLength);//Get User Name iTextLength = sprintf(szBuffer, "User name: %s", szName); MessageBox(0, szBuffer, "User Name", 0); return 0; } 2) I also have the perfect running code of client which uses MFC and sends the status of the client-- that is sends the string from the client which is received at the server. #include "stdafx.h" #include "client.h" #include windows.h #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // The one and only application object UINT sendStatus(); CWinApp theApp; using namespace std; int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) { int nRetCode = 0; sendStatus(); return nRetCode; } UINT sendStatus() { SOCKET client; WSADATA wsaData; //data structure sockaddr_in serveraddr; //sockaddr_in int wsaret=WSAStartup(0x101,&wsaData); //Initialize wsaret variable if(wsaret!=0) { cout<<"Fail to initialize:"; return 0; } struct hostent *hp; unsigned int addr; struct sockaddr_in server; CString servername="localhost"; SOCKET conn; conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(conn==INVALID_SOCKET) return 0; if(inet_addr(servername)==INADDR_NONE) { hp=gethostbyname(servername); } else { addr=inet_addr(servername); hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET); } if(hp==NULL) { cout<<"Fail to get peer address:"; closesocket(conn); return 0; } server.sin_addr.s_addr=*((unsigned long*)hp->h_addr); serve

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups