Sending strings hich recieve data to API calls ? 
Author Message
 Sending strings hich recieve data to API calls ?

Hi,

    I'm using VB 5 and would like so use functions such as
GetPrivateProfileString. I'm declaring the function OK, and the function
call works. However, I do have a problem with the returned data ( in one of
the parameters) -

With GetPrivateProfileString, If I Dim lpReturnedString as a String I get an
error ( which seems to make sense, as the API call requires a C
string/storage space)

If I dim lpReturnedString Like this -

Dim sTemp As String * 255

The function call works, but the string contains unprintable chars after the
correct data

Any help would be appreciated.

Steve



Sat, 03 Feb 2001 03:00:00 GMT  
 Sending strings hich recieve data to API calls ?
Steve,

The return value from GetPrivateProfileString contains the number of
characters actually read.  So just use
    RetStr$ = left$(sTemp, lRet&)
where lRet& is the value returned from the function call.

HTH

Peter


Quote:
>Hi,

>    I'm using VB 5 and would like so use functions such as
>GetPrivateProfileString. I'm declaring the function OK, and the function
>call works. However, I do have a problem with the returned data ( in one of
>the parameters) -

>With GetPrivateProfileString, If I Dim lpReturnedString as a String I get
an
>error ( which seems to make sense, as the API call requires a C
>string/storage space)

>If I dim lpReturnedString Like this -

>Dim sTemp As String * 255

>The function call works, but the string contains unprintable chars after
the
>correct data

>Any help would be appreciated.

>Steve



Sat, 03 Feb 2001 03:00:00 GMT  
 Sending strings hich recieve data to API calls ?

<cut>

Quote:
>If I dim lpReturnedString Like this -
>Dim sTemp As String * 255
>The function call works, but the string contains unprintable chars after
the
>correct data

In this case the return value is the number of valid characters so you can
use Left$ to peel them from the fixed string.  Another option is to use
Instr to find the first 'vbNullChar' and then pull off everything before
that.  Which to use depends on the particular API call -- not all return the
length so for some you have to find the null.


Sat, 03 Feb 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. recieve data asynchronously and send the data on the same socket

2. MSComm does not recieve data when Hyper Terminal recieves data OK

3. Sending XML string to server and recieving without DOM objects

4. Help Needed: Sending/Recieving Text Strings over a LAN

5. Bytes sent/recieved API

6. Send and recieve mail using API

7. Sending and recieving serial data...HOW?

8. Sending data to an LPWSTR in an API call

9. Calling .asm from QB 4.5 and sending text-strings

10. USE API to send string to other program ?

11. Send/Recieve

12. Send / Recieve problem

 

 
Powered by phpBB® Forum Software