CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: INI FILE

  1. #1
    Join Date
    Apr 2001
    Posts
    2

    INI FILE

    C++ Gurus,

    I Would like to create (this i would do it manually) an INI file, and read the properties from this file

    Ex: if system.ini is the file name.

    It would contain the properties like

    System_Name=mysystem
    Visible=true

    From a CPP program i should be able to read the file and get the property i need,

    char *a = getvalue("System_Name");

    How do i do this ?

    Any help on this would be appreiciated

    Thanks!





  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: INI FILE

    you have to read the file into a string variable and then find the position of the start of the text that u want,

    I hope u know how to read the file into string, if not, refer http://vblib.virtualave.net for a function call ReadFileStr in vbFileIO class.

    say you got it into a variable call s,

    then you need to get the start position, like this

    l = instr(s,"System_Name=")

    j = len("System_Name=")
    k = len("mysystem")

    after getting it, you can then use

    x = mid(s,l+j,k)

    if the file is INI, you might want to consider GetPrivateProfileString API to do it.

    cksiow
    http://vblib.virtualave.net - share our codes



  3. #3
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: INI FILE

    Should not this be posted in C forum, to get quicker answer?

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: INI FILE

    DO you want it in C++ or in VB?

    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Apr 2001
    Posts
    2

    Re: INI FILE

    Yes i want this in C++, also if possible could you send me a link to any examples if you have.


    Thanks for all the help!!


  6. #6
    Join Date
    Apr 2000
    Posts
    737

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

Featured