Click here to Skip to main content
15,921,660 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Not an icon but a toolbar drop down arrow Pin
skea11-Aug-03 10:41
skea11-Aug-03 10:41 
GeneralMessage intercept Pin
bitpusher10-Aug-03 16:29
bitpusher10-Aug-03 16:29 
GeneralRe: Message intercept Pin
Fredrik Skog10-Aug-03 22:04
Fredrik Skog10-Aug-03 22:04 
GeneralRe: Message intercept Pin
bitpusher11-Aug-03 5:40
bitpusher11-Aug-03 5:40 
GeneralRe: Message intercept Pin
Fredrik Skog11-Aug-03 20:06
Fredrik Skog11-Aug-03 20:06 
GeneralNeed help in file writing Pin
Snyp10-Aug-03 16:17
Snyp10-Aug-03 16:17 
GeneralRe: Need help in file writing Pin
Nuehli10-Aug-03 19:08
Nuehli10-Aug-03 19:08 
Generalquestion about "char buffer[200]" Pin
10-Aug-03 13:58
suss10-Aug-03 13:58 
I'm new to programming.I received some code: the aim is that the commands are send with the socket-method, and then execute a console program, using the pipe-method. The code is rather long, so here is the fragment with the fault. I tried the following code : (with the aim to find the entire string that I typed in 'char kk', so I could compare it with another string like "help" or "howlong"...)

//////
{
long lEvent=WSAGETSELECTEVENT(lParam);
UINT r;
static char buf[MAXRECVBUF];
DWORD dwNumberOfBytesWrite;
SOCKET sock_tmp;

if (lEvent==FD_ACCEPT){

// "Accept" handler

SOCKADDR_IN clientAddr;
int nClientAddrLen=sizeof(clientAddr);

// Accept connection
if ((sock_tmp=accept(sock_listen,(LPSOCKADDR)&clientAddr,&nClientAddrLen))==INVALID_SOCKET){
if (WSAGetLastError()!=WSAEWOULDBLOCK) return;
}
if (NowUsing==TRUE){
closesocket(sock_tmp);
return;
}

sock=sock_tmp;
send(sock,BANNER,strlen(BANNER),0);
NowUsing=TRUE;

// Boot shell program
sa.nLength = sizeof(sa);
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;

CreatePipe(&hPipeOutputRead,&hPipeOutputWrite,&sa,5000);
CreatePipe(&hPipeInputRead,&hPipeInputWrite,&sa,5000);

memset((void *)&si,0,sizeof(si));
memset((void *)&pi,0,sizeof(pi));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_SHOW;

si.hStdInput = hPipeInputRead;
si.hStdOutput = hPipeOutputWrite;
si.hStdError = hPipeOutputWrite;

CreateProcess (NULL,SHELL_NAME,NULL,NULL,TRUE,0,NULL,START_DIR,&si,&pi);

CloseHandle(hPipeOutputWrite);
CloseHandle(hPipeInputRead);

// Create character read&send thread
hThread_out = CreateThread(NULL,0,OutputToSocket ,NULL,0,&dwChildThreadIdOut);

return;

}else if (lEvent==FD_CLOSE){

// "Close" handler

closesocket(sock);
TerminateProcess(pi.hProcess,0);
TerminateThread(hThread_out,0);
CloseHandle(pi.hProcess);
CloseHandle(hPipeOutputRead);
CloseHandle(hPipeInputWrite);
NowUsing=FALSE;
return;
}
/////start problem-code//////
// Recv packet from client and write to SERVER.EXE
if ((r=recv(sock,(LPSTR)buf,MAXRECVBUF,0))==SOCKET_ERROR) {return;}
kk[i]=buf[0];
kk[i+1]='\0';
MessageBox(NULL,kk,"speciale functie uploaden en zo",MB_OK);
i=i+1;

WriteFile(hPipeInputWrite,&buf,r,&dwNumberOfBytesWrite,NULL);
/////end problem-code//////
}
/////
But now the messagebox always returns:
when I type the 1st character: the first character
when I type the 2nd character: the first character is now a trash character and the second is the character I typed
when I type the 3rd character: the first two character's are now trash character's and the third is the character I typed
...
What should I do so that I can find only the string I typed in "kk", without the trash??
QuestionOleCreateFromFile & Threads - Security Issues? Pin
Florin Ochiana10-Aug-03 11:34
Florin Ochiana10-Aug-03 11:34 
GeneralCant Execute Program! Even with NO ERRORS!?!?!?! Pin
colormyiris10-Aug-03 11:21
colormyiris10-Aug-03 11:21 
GeneralRe: Cant Execute Program! Even with NO ERRORS!?!?!?! Pin
Neville Franks10-Aug-03 12:03
Neville Franks10-Aug-03 12:03 
GeneralRe: Cant Execute Program! Even with NO ERRORS!?!?!?! Pin
Ryan Binns10-Aug-03 22:31
Ryan Binns10-Aug-03 22:31 
QuestionControl Color In Listbox? Pin
MKlucher10-Aug-03 10:59
MKlucher10-Aug-03 10:59 
AnswerRe: Control Color In Listbox? Pin
HPSI10-Aug-03 18:18
HPSI10-Aug-03 18:18 
QuestionPropertySheet - possible to change style OK btn? Pin
michael thomas10-Aug-03 9:25
michael thomas10-Aug-03 9:25 
AnswerRe: PropertySheet - possible to change style OK btn? Pin
Michael Dunn10-Aug-03 12:30
sitebuilderMichael Dunn10-Aug-03 12:30 
GeneralRe: PropertySheet - possible to change style OK btn? Pin
michael thomas10-Aug-03 12:55
michael thomas10-Aug-03 12:55 
GeneralRe: PropertySheet - possible to change style OK btn? Pin
Michael Dunn10-Aug-03 14:52
sitebuilderMichael Dunn10-Aug-03 14:52 
GeneralRe: PropertySheet - possible to change style OK btn? Pin
michael thomas11-Aug-03 9:53
michael thomas11-Aug-03 9:53 
Generalword processor like app Pin
(Steven Hicks)n+110-Aug-03 7:38
(Steven Hicks)n+110-Aug-03 7:38 
GeneralRe: word processor like app Pin
Larry Antram10-Aug-03 7:56
Larry Antram10-Aug-03 7:56 
GeneralRe: word processor like app Pin
(Steven Hicks)n+110-Aug-03 9:14
(Steven Hicks)n+110-Aug-03 9:14 
GeneralRe: word processor like app Pin
Larry Antram10-Aug-03 10:16
Larry Antram10-Aug-03 10:16 
GeneralRe: word processor like app Pin
Snyp10-Aug-03 16:00
Snyp10-Aug-03 16:00 
GeneralRe: word processor like app Pin
jhwurmbach10-Aug-03 21:37
jhwurmbach10-Aug-03 21:37 

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.