Solved

Adding changing ini files

Posted on 1999-01-17
1
140 Views
Last Modified: 2010-05-03
Hi,

I want to get my VB 5.0 program to open win.ini, search through the text to
see if there the program is already listed (useful for removal latter on)
and then add the run = c:\windows\myapp.exe.


Cheers Warren

0
Comment
Question by:isec1
1 Comment
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 1469053
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

Public Function ReadFromINI(ByVal pSection As String, _
                            ByVal pKey As String, _
                            ByVal pDefault As String, _
                            ByVal pPath As String _
                           ) As String
'pSection is the section in the .ini in which you search
'pKey is the word on the left side of the equal sign (=)
'pDefault will be return if the key is not find in the section
'pPath is the file you want to open (with the path)

'strapppl = ReadFromINI("Application", "App1", "Default_Value", "Win.INI")
Dim lngReturn As Long
Dim strReturn As String

    strReturn = String$(200, 0)
    lngReturn = GetPrivateProfileString(pSection, pKey, pDefault, strReturn, Len(strReturn), pPath)
    ReadFromINI = Left$(strReturn, lngReturn)
End Function


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 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