Einzelnen Beitrag anzeigen

Benutzerbild von jokerfacehro
jokerfacehro

Registriert seit: 13. Feb 2007
306 Beiträge
 
Delphi 7 Enterprise
 
#20

Re: Unknown Directive Message

  Alt 2. Mär 2010, 11:28
jop


Delphi-Quellcode:


function WndProc(hWnd: HWND; Msg: UINT; wp: WPARAM;
lp: LPARAM): integer; stdcall; forward;


var

WC:TWndClassEX=(cbSize:SizeOf(TWndClassEX);
     lpfnWndProc:@WndProc;
     lpszClassName:'ATestWndClassEx');




function WndProc(hWnd: HWND; Msg: UINT; wp: WPARAM;
lp: LPARAM): integer; stdcall;
var str:string;
begin
   Result := 0;
  case Msg of

    WM_MY_SOCKET_DATA:
      begin
        setLength(str,1024);
        FillChar(str,Length(str),#0);
        recv(FSocket,str,Length(str),0);
        Showmessage(str);
        //-- WMOnAsyncServerData(wp, lp);
      end;
    WM_MY_SOCKET_ERROR:
      begin
        //-- WMOnAsyncServerError(wp, lp);
      end;
    WM_MY_SOCKET_LOGON:
      begin
        //-- WMOnAsyncServerLogon(wp, lp);
      end;
    WM_MY_SOCKET_CLIENT_DISCONNECT:
      begin
        //-- WMOnAsyncServerDisconnect(wp, lp);
      end;
    WM_CLOSE:
      begin
        DestroyWindow(winhwnd);
      end;
    WM_DESTROY:
      begin
      end;
    else
      Result := DefWindowProc(winhwnd, Msg, wp, lp);
      end;
end;



procedure connectSock(Socket:TSocket;IP:string;Port:Integer);
var SockAddr: TSockAddrIn;
    AddrLen: Integer;

begin
RegisterClassEx(wc);

{winhwnd:=CreateWindowEx(WS_EX_TRANSPARENT  ,
    wc.lpszClassName, '', WS_DISABLED, 0, 0, 0, 0, 0, 0,
      hInstance, nil);// }

winhwnd:=CreateWindowEx(WS_EX_TRANSPARENT,wc.lpszClassName,'12345',0,0,0,0,0,0,0,hInstance,NIL);



Showmessage(syserrormessage(getlasterror));


  AddrLen := SizeOf(SockAddr);
  SockAddr.sin_family := AF_Inet;
  SockAddr.sin_port := htons(Port);
  SockAddr.sin_addr.S_addr := inet_addr(PChar(IP));

  if Connect(Socket, SockAddr, AddrLen) = Socket_Error then
    HandleError;


 { if WSAAsyncSelect(FSocket, winhwnd, WM_mySocket,
    FD_READ or FD_CLOSE or FD_WRITE)= SOCKET_ERROR then
    HandleError;     }

end;


begin

...

connectSock(FSocket,'127.0.0.1',12345);

...

end;



Edit: ich habe für classname mal wc.lpszClassName eingetragen,w as ich vorhin auch schon versucht hatte.
aber irgendwie funktioniert es jetzt
"Never touch a running system administrator !"
  Mit Zitat antworten Zitat