GetPrivateProfileString 
Author Message
 GetPrivateProfileString

I am working with powerbasic Console Compiler and trying to call the
GetPrivateProfileString function from Kernel32.dll (using the $INCLUDE
"WIN32API.INC" of course).  Now i have adapted the following function from
VB to handle the call:

FUNCTION GetFromINI(AppName AS ASCIIZ, KeyName AS ASCIIZ, iniPath AS
ASCIIZ) AS STRING
   DIM RetStr AS ASCIIZ * 255
   GetFromINI = LEFT$(RetStr, GetPrivateProfileString (AppName, KeyName,
"",  RetStr,BYVAL LEN(RetStr), iniPath))
END FUNCTION  

However this does not work.  No compiler errors are given, however a null
is returned.  Thanks in advance for any help!



Mon, 28 May 2001 03:00:00 GMT  
 GetPrivateProfileString

Quote:

> I am working with PowerBasic Console Compiler and trying to call the
> GetPrivateProfileString function from Kernel32.dll (using the $INCLUDE
> "WIN32API.INC" of course).  Now i have adapted the following function from
> VB to handle the call:

> FUNCTION GetFromINI(AppName AS ASCIIZ, KeyName AS ASCIIZ, iniPath AS
> ASCIIZ) AS STRING
>    DIM RetStr AS ASCIIZ * 255
>    GetFromINI = LEFT$(RetStr, GetPrivateProfileString (AppName, KeyName,
> "",  RetStr,BYVAL LEN(RetStr), iniPath))
> END FUNCTION

> However this does not work.  No compiler errors are given, however a null
> is returned.  Thanks in advance for any help!


GetPrivateProfileString, according to my Win3.1 API book, returns an
Int, which is the number of characters copied to the "return string"
buffer.  I would imagine it's fairly similar in Win32, even though MS
may have changed one or two little things.

So using the return value in a LEFT$ function is basically wrong (no pun
intended).

HTH,
--
Paul Pigott

remove the ".sans.spam" to reply


web site  http://www.geocities.com/Eureka/9049



Mon, 28 May 2001 03:00:00 GMT  
 GetPrivateProfileString

Quote:

>So using the return value in a LEFT$ function is basically wrong (no pun
>intended).

Incorrect! Think about it!

However, as you are passing the size of the ASCIIZ buffer with LEN(),
and the buffer has no contents, the LEN() is sending a value of 0!
Change the LEN(buffer) to SIZEOF(buffer).

--Lance.
==============================
Lance Edmonds, Email contacts:



==============================
Please remove "SPAMLESS." when
    replying by email.
==============================



Mon, 28 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. GetPrivateProfileString

 

 
Powered by phpBB® Forum Software