Solved

Adding changing ini files

Posted on 1999-01-17
1
141 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 47
How to debug this code 7 65
Access query that references subform 5 48
Added a column screws up code 5 69
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

749 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