GetPrivateProfileString

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to return a string from an .ini file, and keep getting the
following error:
"Arithmetic operation resulted in an overflow".

Has anyone seen this error before? What am I doing wrong?

Thanks!
 
could you post the code you are using to get the ini value?

The code that I am using is below. The values of the variables are as
follows: psSection: "LogOn", psEntry: "DBType", psDefault: "Microsoft SQL
Server", sReturnVal = Nothing, iBUFFER = 255, psFileName:
"C:\path\setting.ini"

Private Function gsGetProfileString(ByVal psSection As String, ByVal psEntry
As String, ByVal psDefault As String, ByVal psFileName As String) As String

Const iBUFFER As Integer = 255
Dim iLength As Integer
Dim sReturnVal As String

iLength = GetPrivateProfileString(psSection, psEntry, psDefault,
sReturnVal, iBUFFER, psFileName)

gsGetProfileString = Left(sReturnVal, iLength)

End Function
 
in your getprivateprofilestring function try changing the return value from a
sting to a stringbuilder.
when you call the function make sure to initialize the string builder to
your buffer size ie 255.
dim sReturnVal as System.Text.StringBuilder(250);
The string builder should marshel to an LPTSTR that's buffer can be writen to.
Aaron
 
Back
Top