Results 1 to 14 of 14

Thread: ini files

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2001
    Location
    Newcastle, UK
    Posts
    50

    Question

    I'm makeing a small program that edits an ini file, it works but the problem is that the ini file that I am editing's titles are formated like this: [ title ] unless I manualy chainge them to: [title] it doesn't work.

    I have tryed: lpappname = " title " but it still doesn't work unless the format in the ini is [title]

    TIA,
    Alex

  2. #2
    Addicted Member rbnwares's Avatar
    Join Date
    Sep 2000
    Location
    Philippines
    Posts
    142

    Red face

    What do u mean?
    Stupidity is better than cure.

    VB6 SP5 Enterprise Ed.
    C, Pascal, VC++ 6.0


    Running Win98 SE and Win2000 Prof. Ed.


    Email me at : [email protected]

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2001
    Location
    Newcastle, UK
    Posts
    50
    the program will only retrive information from the ini file if the titles in the ini are writen like this: [title] if they are writen as [ title ] I get an error mesage e.g.

    [Joy]
    allow_force_feedback=1
    force_feedback_damping=150.000000
    force_feedback_latency=0.025000
    max_steering_torque=300.000000

    but in the actual ini they are writen like this:

    [ Joy ]
    allow_force_feedback=1
    force_feedback_damping=150.000000
    force_feedback_latency=0.025000
    max_steering_torque=300.000000

    how do I specify that there will be spaces between the [ and the title in my VB code e.g.

    lpappname = "joy"

    lpappname = " joy " doesn't work
    Last edited by tino; Mar 27th, 2001 at 01:23 PM.

  4. #4
    New Member
    Join Date
    Mar 2001
    Location
    France
    Posts
    13
    what's the code you use to get the content of the ini file, the api functions or you have made them on your own?

  5. #5
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    Use API functions. It is SO easy once you used the API.

    I also had the same trouble.
    "If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"

  6. #6

    Thread Starter
    Member
    Join Date
    Mar 2001
    Location
    Newcastle, UK
    Posts
    50
    yep I'm useing the API functions and it works fine apart from those bloudy spaces

  7. #7
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155
    I do not use API when I can use plain VB code. Why don't you remove the punctation manually?


    Quintonir

  8. #8
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    hmmm...that is interesting....

    I had the problem with the spaces when I used plain VB code, but when I changed to API function the problem was gone.

    I got the code snippet from a user here named Matthew Gates. Maybe he can direct you further.....he seems to be VERY knowlegable.
    "If I had known it was going to be that kinda party, I would have stuck my disk in the mash potatos!"

  9. #9

    Thread Starter
    Member
    Join Date
    Mar 2001
    Location
    Newcastle, UK
    Posts
    50
    I have maualy edited it but I'm planning to distribute the program and I couldn't expect everyone else to do that. How could I use plain VB code to do the Same thing without over complicateing things?

  10. #10
    Addicted Member Quintonir's Avatar
    Join Date
    Mar 2001
    Location
    The Netherlands
    Posts
    155
    Shall I state a self-made Replace() function?

  11. #11
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    If you are using VB6, you could use the REPLACE function to format these spaces :
    Code:
    Dim StrFile as String
    StrFile = "C:\Name_Of_File.ini"
    
    Replace "[ ", StrFile, "["
    Replace " ]", StrFile, "]"
    This will only work if there's one space between the bracket & the word, and I am 99% sure that this is only for VB6. But, it might be able to help you, use the above before you retrieve the ini file information.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  12. #12
    Lively Member
    Join Date
    Feb 2001
    Location
    Jutland, Denmark
    Posts
    71
    I use API and don't have this problem
    se my module
    Attached Files Attached Files

  13. #13

    Thread Starter
    Member
    Join Date
    Mar 2001
    Location
    Newcastle, UK
    Posts
    50
    I can't seem to get that module working, could you post some sample code?

    this is the module I was useing:
    Code:
    Public Declare Function WritePrivateProfileString _
    Lib "kernel32" Alias "WritePrivateProfileStringA" _
    (ByVal lpApplicationname As String, _
    ByVal lpKeyName As Any, _
    ByVal lsString As Any, _
    ByVal lplFilename As String) As Long
    
    
    Public Declare Function GetPrivateProfileInt _
    Lib "kernel32" Alias "GetPriviteProfileIntA" _
    (ByVal lpApplicationname As String, _
    ByVal lpKeyName As String, _
    ByVal nDefault As Long, _
    ByVal lpFileName As String) As Long
    
    
    Public Declare Function GetPrivateProfileString _
    Lib "kernel32" Alias "GetPrivateProfileStringA" _
    (ByVal lpApplicationname As String, _
    ByVal lpKeyName As String, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString As String, _
    ByVal nSize As Long, _
    ByVal lpFileName As String) As Long
    TIA,
    Alex

  14. #14
    Lively Member
    Join Date
    Feb 2001
    Location
    Jutland, Denmark
    Posts
    71
    Here we Go.
    Some of the variables are there only to help debugging
    Hope it help you
    Benny
    Attached Files Attached Files

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