Results 1 to 3 of 3

Thread: INI files

  1. #1
    jayroy
    Guest

    INI files

    Can anyone see anything wrong with this?

    I keep getting a runtime errror 49 "bad DLL calling convention". I am using a "c:\apps\stock\test.ini" file and trying to retrieve a "fred" variable


    Private Declare Function GetPrivateProfileString Lib "kernel32"
    Alias _
    "GetPrivateProfileStringA" _
    (ByVal lpAppName As String, _
    ByVal lpKeyName As String, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString As String, _
    ByVal nSize As Long, _
    ByVal lpFileName As String)


    Private Sub Command1_Click()
    Dim nChar As Long
    Dim ReturnedString As String
    Dim Parsed() As String 'not used

    ReturnedString = String(512, 0)
    nChar = GetPrivateProfileString("test", "fred", "", ReurnedString, 512, "c:\apps\stock\test.ini")
    Debug.Print (nChar)
    End Sub

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    I'm doing a completely different thing and getting the same error. Can anyone help?

    My code (peices)
    VB Code:
    1. Declare Function GetPrivateProfileString Lib "kernel32" _
    2.   Alias "GetPrivateProfileStringA" _
    3.   (ByVal lpApplicationName As String, _
    4.    ByVal lpKeyName As String, _
    5.    ByVal lpDefault As String, _
    6.    ByVal lpReturnedString As String, _
    7.    ByVal nSize As Long, _
    8.    ByVal lpFileName As String) As Long
    9.  
    10. Public Function Devour(ByVal FullFileName As String) As Long
    11.   Dim ReturnedString As String
    12.   Dim ReturnedSize As Long
    13.  
    14.   ReturnedSize = GetPrivateProfileString ("Properties", "WorkStation", "", ReturnedString, 256, FullFileName)
    15. End Function

    My error
    The instruction at "0x77e873dc" referenced memory at "0x00000000". The memory could not be "written".
    Course, the wording on my error isn't but so important. It looks like it is trying to write to a bogus memory address. I've stepped through the code, and I get the error on the API call. The error is bad enough to crash Studio.

    I'm using VS6 on W2KPro.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  3. #3
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    Never mind, I just fixed my own problem.

    VB Code:
    1. Public Function Devour(ByVal FullFileName As String) As Long
    2.   Dim ReturnedString As String * 256
    3.   Dim ReturnedSize As Long
    4.  
    5.   ReturnedSize = GetPrivateProfileString ("Properties", "WorkStation", "", ReturnedString, 256, FullFileName)
    6. End Function

    You have to give the string a length.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width