Hola :
les envio un pequeño proyecto realizado con HMG.3.2 que usa las Api de windows , el cual al intentar pasarlo a HMG.3.4.0 da un mensaje de error por la falta de un archivo de MINGW y por lo tanto no crea el ejecutable .
Obsevo que la estructura de archivos de MINGW entre HMG3.2 y HMG.3.4 son muy dintintas .
Saludos .
Mario Rafael Mansilla
HMG.3.4.0 error con api de windows
Moderator: Rathinagiri
-
- Posts: 270
- Joined: Wed Aug 13, 2008 2:35 pm
- Location: Córdoba - Argentina
-
- Posts: 270
- Joined: Wed Aug 13, 2008 2:35 pm
- Location: Córdoba - Argentina
Re: HMG.3.4.0 error con api de windows
Hola :
solucione el inconveniente copiando el archivo aygshell.h de la carpeta hmg.3.3.1\mingw\include a la carpeta hmg.3.4.0\mingw\i86-w64-mingw32\include debido a que este archivo no se encontraba en la version hmg.3.4.0 .
Saludos
Maro Mansilla
solucione el inconveniente copiando el archivo aygshell.h de la carpeta hmg.3.3.1\mingw\include a la carpeta hmg.3.4.0\mingw\i86-w64-mingw32\include debido a que este archivo no se encontraba en la version hmg.3.4.0 .
Saludos
Maro Mansilla
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: HMG.3.4.0 error con api de windows
Hi Mario,
this is not a API bug.
The aygshell.h file is not necessary, is a header file for Windows CE.
I corrected the data type conversion in your C code (avoids compiler warnings).
This is the corrected file Rs232.prg:
this is not a API bug.
The aygshell.h file is not necessary, is a header file for Windows CE.
I corrected the data type conversion in your C code (avoids compiler warnings).
This is the corrected file Rs232.prg:
Code: Select all
*---------------------
* Programa : RS232.prg
*---------------------
#include <minigui.ch>
*------------------
Function Init_com(nPort , nBaud , nDatabyte , nStopbits )
* nPort : Puerto com 1 .. 9
* nBaud : Velocidad comunicacion
* nStopbits : Bits de Stop
*------------------
Local nCom
Local continuar := .T.
Local nStop
nCom := "COM" + Str(nPort,1) + ":"
Do Case
Case nStopbits = 1
nStop = 0
Case nStopbits = 2
nStop = 2
Endcase
Handler := Opencom(nCom)
If Handler < 0
MsgInfo("Error abriendo " + nCom ,"Comunicación")
Continuar := .F.
Endif
If Continuar
IF !SetComm( handler, nBaud , 0, nDataByte, nStop)
MsgInfo("Fallo al configurar com")
Continuar := .F.
Closecom( Handler )
ENDIF
Endif
If ! Continuar
Closecom( Handler )
Else
prtcom := .T.
Endif
Return Continuar
*----------------------------------
Function ComSend( Handler, cString )
*----------------------------------
LOCAL Continuar
LOCAL nBytesend, nBytes:= Len( cString )
nByteSend := WriteComm( Handler, @cString, nBytes )
cRest := nBytes - nByteSend
Do while cRest > 0
cString := Right(cString,cRest)
nBytes := Len(cString)
nByteSend := WriteComm(Handler, @cString , nBytes)
cRest := nBytes - nBytesSend
Enddo
If cRest = 0
Continuar := .T.
Else
Continuar := .F.
Endif
Return Continuar
*--------------------
Function Escribircom(String)
*--------------------
Continuar := .F.
*-- envio datos
Continuar := Comsend(Handler,String)
Return Continuar
#pragma BEGINDUMP
#define BUFF_IN 1024
#define BUFF_OUT 1024
#define GENERIC_READ 0x80000000
#define GENERIC_WRITE 0x40000000
#define OPEN_EXISTING 3
#define INVALID_HANDLE_VALUE -1
#define FILE_ATTRIBUTE_NORMAL 0x00000080
#define NOPARITY 0
#define ODDPARITY 1
#define EVENPARITY 2
#define MARKPARITY 3
#define SPACEPARITY 4
#define ONESTOPBIT 0
#define ONE5STOPBITS 1
#define TWOSTOPBITS 2
#include <windows.h>
#include <winbase.h>
#include <hbapi.h>
HB_FUNC( OPENCOM )
{
HANDLE handle ;
DWORD dwError;
handle = CreateFile(hb_parc( 1 ),( GENERIC_READ | GENERIC_WRITE ), 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if(handle == INVALID_HANDLE_VALUE)
{
dwError = GetLastError();
printf("Error Createfile \n");
printf("Error %lu\n",dwError);
}
hb_retnl((LONG) handle );
}
HB_FUNC( CLOSECOM )
{
CloseHandle( (HANDLE) hb_parnl( 1 ) ) ;
}
HB_FUNC( SETCOMM )
{
DCB dcb;
COMMTIMEOUTS timeouts;
BOOL lsuccess;
DWORD dwError;
SetupComm(( HANDLE) hb_parnl( 1 ), BUFF_IN, BUFF_OUT ) ;
lsuccess = GetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb );
if (!lsuccess)
{
// Handle the error.
dwError = GetLastError();
printf("Error GetCommstate \n");
printf("Error %lu\n" , dwError);
}
dcb.BaudRate = hb_parni( 2 );
dcb.Parity = hb_parni( 3 );
dcb.ByteSize = hb_parni( 4 );
dcb.StopBits = hb_parni( 5 );
dcb.fBinary = TRUE;
dcb.fParity = TRUE;
dcb.fOutxCtsFlow = FALSE;
dcb.fOutxDsrFlow = FALSE;
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fDsrSensitivity = FALSE;
dcb.fTXContinueOnXoff = FALSE;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.fErrorChar = FALSE;
dcb.fNull = FALSE;
dcb.fRtsControl = RTS_CONTROL_DISABLE;
dcb.fAbortOnError = FALSE;
lsuccess = GetCommTimeouts(( HANDLE) hb_parnl( 1 ) , &timeouts);
if (!lsuccess)
{
// Handle the error.
dwError = GetLastError();
printf("Error GetCommTimeouts \n");
printf("Error %lu\n" , dwError);
}
timeouts.ReadIntervalTimeout = 0;
timeouts.ReadTotalTimeoutMultiplier = 0;
timeouts.ReadTotalTimeoutConstant = 1000;
timeouts.WriteTotalTimeoutMultiplier = 0;
timeouts.WriteTotalTimeoutConstant = 0;
lsuccess = SetCommTimeouts(( HANDLE) hb_parnl( 1 ), &timeouts );
if (!lsuccess)
{
// Handle the error.
dwError = GetLastError();
printf("Error SetCommTimeouts \n");
printf("Error %lu\n" , dwError);
}
lsuccess = SetCommState( ( HANDLE ) hb_parnl( 1 ), &dcb );
if (!lsuccess)
{
// Handle the error.
dwError = GetLastError();
printf("Error SetCommState \n");
printf("Error %lu\n" , dwError);
}
hb_retl(lsuccess);
}
HB_FUNC( READCOMM )
{
DWORD dw = 0;
ReadFile( ( HANDLE ) hb_parnl( 1 ), ( LPVOID ) hb_parc( 2 ), ( DWORD ) hb_parni( 3 ), &dw, NULL );
hb_retni( ( int ) dw ? ( int ) dw : -1 );
}
HB_FUNC( WRITECOMM )
{
DWORD dw = 0;
WriteFile( (HANDLE ) hb_parnl( 1 ), ( LPVOID ) hb_parc( 2 ), ( DWORD ) hb_parni( 3 ), &dw, NULL );
hb_retni( ( int ) dw ? ( int ) dw : -1);
}
#pragma ENDDUMP
-
- Posts: 270
- Joined: Wed Aug 13, 2008 2:35 pm
- Location: Córdoba - Argentina
Re: HMG.3.4.0 error con api de windows
Hola Claudio :
perfecto muchas gracias , implemento las modificaciones en el sistema completo y cualquier cosa te consulto .
Saludos
Mario Mansilla
perfecto muchas gracias , implemento las modificaciones en el sistema completo y cualquier cosa te consulto .
Saludos
Mario Mansilla