Solved

INI files

Posted on 1998-08-12
3
230 Views
Last Modified: 2010-04-30
Hi,
Could someone enlighten me on INI files ? How does one create and use them.
Thanks,

PM
0
Comment
Question by:PriyaMani
3 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
ID: 1468657
To create and use INI files you will have to add to API declares to your project:
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
An INI files contents are in this layout:
  <ApplicationName>
  KeyName=Value
To write to an INI file use this call:
  lRes = WritePrivateProfileString("MyAppName", "MyKeyName", "MyValue", "MyApp.ini")
This will create (if it doesn't already exist) a file called MyApp.ini in the windows directory.  The contents will be:
  <MyAppName>
  MyKeyName=MyValue
To retrieve the value, use this code:
  Dim sBuffer As String * 255
  lRes = GetPrivateProfileString("MyAppName", "MyKeyName", sBuffer, Len(sBuffer), "DefaultValue", "MyApp.ini")
  Debug.Print Left$(sBuffer, lRes)
This will print the value above.  If the value doesn't exists, it will print:
  DefaultValue.
0
 
LVL 3

Expert Comment

by:jjmartin
ID: 1468658
Post your email address, and I will send you an excelent word doc on using ini files.
0
 

Author Comment

by:PriyaMani
ID: 1468659
Will take some time to understand & try out the proposed answer. In the meantime,

For jjmartin:
My email address : marie4@ameritech.net
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now