Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

call windows apis GetPrivateProfileString and WritePrivateProfileString

Deleted_U_Intel
Employee
957 Views
Why don't work this sub???
CHARACTER*(*) FUNCTION LEERVALOR(FICHERO,SECCION,CLAVE)
USE KERNEL32
CHARACTER*(*) FICHERO,SECCION,CLAVE
INTEGER*4 I
CHARACTER*300 CADENA

DO I=1,300
CADENA(I:I)=' '
ENDDO

I = GetPrivateProfileString(SECCION, CLAVE, '', CADENA, LEN_TRIM(CADENA), FICHERO)
IF (I > 0) THEN
LEERVALOR= TRIM(CADENA)
ELSE
LEERVALOR = ""
ENDIF
END FUNCTION
I use this sub to read from a INI file but the routine getprivateprofilestring returns I=0. Why???
I use the same routine in VB and works correctly.
This sub don't work too...
SUBROUTINE GUARDAVALOR(FICHERO,SECCION,CLAVE,VALOR)
USE KERNEL32
CHARACTER*(*) FICHERO,SECCION,CLAVE,VALOR
INTEGER*4 I

I = WritePrivateProfileString(SECCION, CLAVE, VALOR, FICHERO)

END

Message Edited by davidzorro68@hotmail.com on 11-22-2004 01:18 AM

0 Kudos
2 Replies
anthonyrichards
New Contributor III
957 Views
You specify LEN_TRIM(CADENA) as the length of the buffer to recieve the returned string, but LEN_TRIM returns length after stripping trailing blanks, and CADENA is filled with blanks, so maybe it objects to a zero length (after stripping blanks) buffer?
0 Kudos
Jugoslav_Dujic
Valued Contributor II
957 Views
Is FICHERO properly char(0) terminated?
Jugoslav
0 Kudos
Reply