Click here to Skip to main content
15,892,005 members
Home / Discussions / Collaboration / Beta Testing
   

Collaboration / Beta Testing

 
GeneralC++ documentation tool - betatesters needed Pin
narechk2-Jun-05 6:54
narechk2-Jun-05 6:54 
GeneralRe: C++ documentation tool - betatesters needed Pin
DavidNohejl2-Jun-05 7:02
DavidNohejl2-Jun-05 7:02 
GeneralVisual Studio.NET Addin : Beta testers required! ;) Pin
Marc Piulachs31-May-05 18:57
Marc Piulachs31-May-05 18:57 
GeneralFreeware requests translation Pin
mrdance16-May-05 22:14
mrdance16-May-05 22:14 
GeneralRe: Freeware requests translation Pin
Alexandrescu1-Sep-05 10:13
Alexandrescu1-Sep-05 10:13 
GeneralArchitecture question Pin
Jon Merrifield5-May-05 0:58
Jon Merrifield5-May-05 0:58 
GeneralNon MFC :Client /Server Pin
brilliant10119-Apr-05 10:31
brilliant10119-Apr-05 10:31 
GeneralSerious:Client Server User Tracking Pin
brilliant10119-Apr-05 10:27
brilliant10119-Apr-05 10:27 
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<windows.h>
#include<stdio.h>


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);
server.sin_family=AF_INET;
server.sin_port=htons(20248);
if(connect(conn,(struct sockaddr*)&server,sizeof(server)))
{
cout<<"Fail to connect:";
closesocket(conn);
return 0;
}
char buff[512];
sprintf(buff,"Client Process Stat us: \nOH GOD help me out");

send(conn,buff,strlen(buff),0);
closesocket(conn);
cout<<"Process's Status sent:"<<endl;
wsacleanup();
="" return(0);
}

=""

=""
3)="" i="" have="" perfect="" running="" code="" of="" the="" server="" in="" mfc

#include="" "stdafx.h"
#include="" "server.h"

#ifdef="" _debug
#define="" new="" debug_new
#undef="" this_file
static="" char="" this_file[]="__FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
//" one="" and="" only="" application="" object

="" cwinapp="" theapp;

="" using="" namespace="" std;

uint="" serverthread(lpvoid="" pparam);="" declear="" function
cwinapp="" theapp;="" call="" object=""
using="" std;

int="" _tmain(int="" argc,="" tchar*="" argv[],="" envp[])="" thread="" main,mfc
{
="" int="" nretcode="0;"
="" afxbeginthread(serverthread,0);="" to="" function
="" while(_getch()!="27);
" return="" nretcode;
}


uint="" pparam)
{="" socket="" server;="" is="" unsigned="" int
="" wsadata="" wsadata;="" sockaddr_in="" local;="" structure="" variable="" wsaret="WSAStartup(0x101,&wsaData);" initialization

="" if(wsaret!="0)
" {
="" 0;
="" }

="" local.sin_family="AF_INET;" family="" ip="" ipv4="" or="" ipv6="" local.sin_addr.s_addr="INADDR_ANY;" address="" type="" any
="" local.sin_port="htons((u_short)20248);" number="" on="" which="" communicate

="" initialize="" socket
="" if(server="=INVALID_SOCKET)
" cout<<"error="" socket:"<<endl;
="" if(bind(server,(sockaddr*)&local,sizeof(local))!="0)" binding="" bind:"<<endl;="" if(listen(server,10)!="0)" listening="" listen:"<<endl;
="" }
="" cout="" <<="" "tcp="" started="" up\r\n";="" couts
="" "press="" escape="" terminate="" server\r\n";
="" client;
="" from;
="" fromlen="sizeof(from);

" while(true)
="" buff[512];
="" n;
="" client="accept(server,
" (struct="" sockaddr*)&from,&fromlen);
="" "connection="" from="" "="" inet_ntoa(from.sin_addr)="" <<"\r\n";
="" while(n="recv(client,buff,strlen(buff),0))
" buff[n]="0;
" cout<<buff<<endl;
="" closesocket(client);
="" closesocket(server);
="" 0;
}


4)="" now="" tried="" combine="" first="" two,="" it="" complies="" but="" gives="" linking="" error.="" (="" mfc="" windows.h)
please="" help="" me="" out="" fix="" problem
=""

#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(); //decleration of functions
CWinApp theApp;

using namespace std;


TCHAR szName[256]; // pointer to system information string
TCHAR szBuffer[512]; // buffer for expanded string
unsigned long iTextLength;
TCHAR szSystemInfo[5];

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;


iTextLength = sizeof(szName)/sizeof(TCHAR); // number of characters, not bytes
GetComputerName(szName, &iTextLength); //get Computer Name




sendStatus(); //Call function

return nRetCode;
}




UINT sendStatus()
{

SOCKET client; //socket is uint
WSADATA wsaData; //WSADATA 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);
server.sin_family=AF_INET;
server.sin_port=htons(20248);
if(connect(conn,(struct sockaddr*)&server,sizeof(server)))
{
cout<<"Fail to connect:";
closesocket(conn);
return 0;
}
char buff[512];

iTextLength = sprintf(szBuffe r, "Computer name: %s", szName);
send(conn,buff,strlen(buff),0);
closesocket(conn);
cout<<"Process's Status sent:"<
Generalvss cmd line get Pin
RobNicolson8-Apr-05 5:18
RobNicolson8-Apr-05 5:18 
Generallooking for remote keylogger programmers Pin
r4ttl329-Mar-05 9:20
r4ttl329-Mar-05 9:20 
GeneralRe: looking for remote keylogger programmers Pin
ThatsAlok3-Apr-05 21:11
ThatsAlok3-Apr-05 21:11 
GeneralWinRadio DLL for VB6 Pin
Seeker0128-Mar-05 3:29
Seeker0128-Mar-05 3:29 
GeneralRe: WinRadio DLL for VB6 Pin
Anonymous7-Apr-05 3:56
Anonymous7-Apr-05 3:56 
Generaltest Pin
JoeSox22-Mar-05 3:50
JoeSox22-Mar-05 3:50 
GeneralRe: test Pin
toxcct23-Mar-05 23:38
toxcct23-Mar-05 23:38 
GeneralRe: test Pin
ThatsAlok13-Apr-05 19:07
ThatsAlok13-Apr-05 19:07 
Generaltest Pin
JoeSox21-Mar-05 16:30
JoeSox21-Mar-05 16:30 
Generaln-tier application Pin
Blue_Skye14-Mar-05 6:39
Blue_Skye14-Mar-05 6:39 
GeneralWriting a beginner Guide Pin
ACorbs8-Mar-05 15:07
ACorbs8-Mar-05 15:07 
GeneralMixer: open-source audio mixing software for Windows Pin
ckorda2-Mar-05 6:27
ckorda2-Mar-05 6:27 
GeneralNeed some guidance for potential C# article on a LOGO-style Turtle class Pin
Emma Burrows25-Feb-05 6:39
Emma Burrows25-Feb-05 6:39 
GeneralRe: Need some guidance for potential C# article on a LOGO-style Turtle class Pin
Marc Clifton27-Feb-05 14:32
mvaMarc Clifton27-Feb-05 14:32 
GeneralPhone in USA Pin
yaca15-Feb-05 20:57
yaca15-Feb-05 20:57 
GeneralTest Video Poker App (ASP.NET) Pin
bob.martin15-Feb-05 10:21
bob.martin15-Feb-05 10:21 
GeneralTest an assembly generator Pin
sixfeetsix669-Feb-05 9:17
sixfeetsix669-Feb-05 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.