Solved

INI files

Posted on 1998-08-12
3
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 96
VB6 - Compare and highlight cell not the same 3 63
Excel Automation VBA 19 116
VBA Replace Function - What am I missing? 3 52
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 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