000
17.01.2004, 19:06 Uhr
~Simonko
Gast
|
Dieses Programm sollte den buffer vom receive in eine textbox speichern. Aber es geht irgendwie nicht. Kann mir mal jemand helfen?
C++: |
#include "stdafx.h" #include "resource.h" #include "stdio.h" #include "winsock.h" #define WM_WSAASYNC (WM_USER +1) #define WSAGETSELECTERROR(lParam) HIWORD(lParam) #define WSAGETSELECTEVENT(lParam) LOWORD(lParam) HINSTANCE hInstance; LRESULT CALLBACK Ksenja(HWND, UINT, WPARAM, LPARAM); int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, (LPCTSTR)IDD_MAIN, 0, (DLGPROC)Ksenja); return 0; } LRESULT CALLBACK Ksenja(HWND hDlg, UINT ksenja, WPARAM wParam, LPARAM lParam) { WORD wEvent,wVersionRequested; WSADATA wsaData; SOCKET sock21; sockaddr_in sock_in21; char identify[34]="nick Simonko\n user ksenja 0 0 0\n"; char mess[3000]; static char buf[10000];
switch (ksenja) { case WM_CLOSE: EndDialog(hDlg, 0);
case WM_COMMAND: case WM_WSAASYNC: wEvent=WSAGETSELECTEVENT(lParam); switch (wEvent){ case FD_READ: recv(sock21,(char*)&buf,sizeof(buf),0); SetWindowText(GetDlgItem(hDlg,IDC_OUT),buf); //system("C:\\WINDOWS\\System32\\command.com"); return(0); } switch(wParam) { case IDC_OK: wVersionRequested = MAKEWORD( 2, 0 ); WSAStartup( wVersionRequested, &wsaData ); sock21 = socket(PF_INET, SOCK_STREAM, 0); sock_in21.sin_family = PF_INET; sock_in21.sin_port = htons (6667); sock_in21.sin_addr.S_un.S_un_b.s_b1=127; sock_in21.sin_addr.S_un.S_un_b.s_b2=0; sock_in21.sin_addr.S_un.S_un_b.s_b3=0; sock_in21.sin_addr.S_un.S_un_b.s_b4=1; connect(sock21,(struct sockaddr*)&sock_in21,sizeof(struct sockaddr)); WSAAsyncSelect(sock21,hDlg,WM_WSAASYNC,(FD_READ)); return(0); case IDM_EXIT: EndDialog(hDlg,0); break; case ID_ABOUT: DialogBox(hInstance, (LPCTSTR)IDD_DIALOG1, hDlg, (DLGPROC)Ksenja); break; } } return (0); }
|
Bearbeitung von Pablo: |
CPP tags gesetzt
|
Dieser Post wurde am 17.01.2004 um 19:09 Uhr von Pablo editiert. |