Ahora mismo las pruebo
Saludos.
Antonio Linares wrote:Esta es la primera función que has localizado y creo que es la que tiene más posibilidades de funcionar bien. No le falta nada:
http://www.pocketpcjunkies.com/Uwe/Foru ... nting-FREECode: Select all
#include "FWCE.ch" function Main() IrdaPrint( "Hello World!" ) return nil #pragma BEGINDUMP #include <hbapi.h> #include <windows.h> #define _WIN32_WCE #include <WinSock2.h> #include <af_irda.h> #define NUMRETRY 10 // No está definido en el ejemplo. Usamos 10 a ver que tal HB_FUNC( IRDAPRINT ) // cText { SOCKET sock; // Socket bound to the server DEVICELIST devList; // Device list int iCount = 0, // Number of retries index = 0, // Integer index iDevListLen = sizeof(devList); // Size of the device list TCHAR szError[ 100 ]; // Error message string WSADATA wsaData; WORD wVersion = MAKEWORD( 1, 1 ); // Winsock Version 1.1 BYTE IASQueryBuff[ sizeof( IAS_QUERY ) - 3 + IAS_MAX_ATTRIBNAME ]; int IASQueryLen = sizeof( IASQueryBuff ); PIAS_QUERY pIASQuery = ( PIAS_QUERY ) &IASQueryBuff; char szServiceName[ 12 ]; SOCKADDR_IRDA iraddr; struct linger l; if( WSAStartup( wVersion, &wsaData ) != 0 ) { wsprintf( szError, TEXT( "WSAStartup failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "error" ), 0 ); return; } // Create a socket that is bound to the server. if( ( sock = socket( AF_IRDA, SOCK_STREAM, 0 ) ) == INVALID_SOCKET ) { wsprintf( szError, TEXT( "Allocating socket failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "error" ), 0 ); WSACleanup(); return; } // Initialize the number of devices to zero. devList.numDevice = 0; while( ( devList.numDevice == 0 ) && ( iCount <= NUMRETRY ) ) { // Retrieve the socket option if( getsockopt( sock, SOL_IRLMP, IRLMP_ENUMDEVICES, ( char * ) &devList, &iDevListLen) == SOCKET_ERROR ) { wsprintf( szError, TEXT( "Server could not be located, getsockopt failed. Error: %d"), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "Error" ), 0 ); closesocket( sock ); WSACleanup(); return; } if( devList.numDevice == 0 ) { iCount++; Sleep( 1000 ); } } if( iCount > NUMRETRY ) { MessageBox( 0, TEXT( "Server could not be located!" ), TEXT( "Error" ), 0 ); closesocket( sock ); WSACleanup(); return; } memcpy( &pIASQuery->irdaDeviceID, devList.Device[ 0 ].irdaDeviceID, 4 ); memcpy( &pIASQuery->irdaClassName, "IrLPT", 6 ); memcpy( &pIASQuery->irdaAttribName, "IrDA:IrLMP:LsapSel", 19 ); if( getsockopt( sock, SOL_IRLMP, IRLMP_IAS_QUERY, ( char * ) pIASQuery, &IASQueryLen) == SOCKET_ERROR ) { wsprintf( szError, TEXT( "getsockopt failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "Error" ), 0 ); closesocket( sock ); WSACleanup(); return; } sprintf( szServiceName, "LSAP-SEL%d", pIASQuery->irdaAttribute.irdaAttribInt ); memset( &iraddr, 0, sizeof( iraddr ) ); iraddr.irdaAddressFamily = AF_IRDA; memcpy( iraddr.irdaDeviceID, devList.Device[ 0 ].irdaDeviceID, 4 ); memcpy( iraddr.irdaServiceName, szServiceName, strlen( szServiceName ) + 1 ); // Establish a connection to the socket. if( connect( sock, ( struct sockaddr * ) &iraddr, sizeof( iraddr ) ) == SOCKET_ERROR ) { wsprintf( szError, TEXT( "Connecting to the server failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "Error" ), MB_OK ); closesocket( sock ); WSACleanup(); return; } // Turn on SO_LINGER l.l_onoff = 1; l.l_linger = 0; if( setsockopt( sock, SOL_SOCKET, SO_LINGER, ( char * ) &l, sizeof( struct linger ) ) == SOCKET_ERROR ) { wsprintf( szError, TEXT( "setsockopt failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "Error" ), MB_OK ); closesocket( sock ); WSACleanup(); return; } // Send a string from the client socket to the server socket. if( send( sock, hb_parc( 1 ), hb_parclen( 1 ) + 1, 0 ) == SOCKET_ERROR ) { wsprintf( szError, TEXT( "Sending data to the server failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "Error" ), MB_OK ); closesocket( sock ); WSACleanup(); return; } // Close the socket. if( closesocket( sock ) == SOCKET_ERROR ) { wsprintf( szError, TEXT( "closesocket failed. Error: %d" ), WSAGetLastError() ); MessageBox( 0, szError, TEXT( "Error" ), 0 ); WSACleanup(); return; } WSACleanup(); } #pragma ENDDUMP