Solved

Adding changing ini files

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
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 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…

757 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