🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.visual
Article #322

Re: HELP !!! ... How i can read INI files in VB4 ....

#322
From: Mark Wilson
Date: Mon, 28 Apr 1997 00:00
71 lines
3572 bytes
Use the following API calls:

Copy it from here and paste into a moudle in the declare area.  NOTE: 
These are 16 bit calls, but the 32 bit are not too different.  Us the VB
API text viewer which is in 4.0 32bit and VB 5.0 to find the 32bit
versions.

'windows API function to find the windows directory

Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As
String, ByVal nSize As Integer) As Integer

'windows API function to get from the WIN.INI

Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName As
String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal
lpReturnedString As String, ByVal nSize As Integer) As Integer

'windows API function to write to the WIN.INI

Declare Function WriteProfileString Lib "Kernel" (ByVal
lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As
Any) As Integer

'windows API function to get from your own INI

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal
lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As
String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal
lpFileName As String) As Integer

'windows API function to write to your own INI

Declare Function WritePrivateProfileString Lib "Kernel" (ByVal
lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As
Any, ByVal lplFileName As String) As Integer

Here is how I used it.  NOTE the GET and WRITE parts:

ReturnedSize = GetPrivateProfileString("PathToDataBases", "PROJECT",
DefaultString, ReturnedString, 255, "Holywood.ini")

ReturnedSize = WritePrivateProfileString("PathToDataBases", "PROJECT",
"J:\PROJECT\CL_SERV\PROJECT.MDB", "Holywood.ini")

-- 
Check out Virtual Enterprises:
http://dspace.dial.pipex.com/virtual/index.htm
FREE technology Ezine!!  A dynamic place where business users and
software developers are meeting.


James Chambers wrote:
> 
> In article <01bc4bb2$2eb66ae0$62011bc8@tiburon>, jcaldero@ctc-mundo.net says...
> >
> >Hi !
> >
> >I need help !!!
> >In VB3 i use the getProfile function to read .INI files but in VB4 it reads
> >only one time and when there�s some change in the INI file and i try read
> >the .INI file again, I CAN�T SEE THE CHANGES.
> >Someone knows another way to read .INI files (and changes over these files)
> >in VB4 over Win 3, Win 95 and WinNT 4.0 WS.
> >Your help would be much appreciated.
> 
>         I have used getsetting and savesetting in VB 4.0 32 bit and 16 bit with
> very good results.  Let me know if you need some code examples.  In 32 bit, it
> writes to the system registry as opposed to the .INI.  I am not sure if this
> can be changed or not.
Technical Details
Message-ID: <33644BF1.AC0@dial.pipex.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <01bc4bb2$2eb66ae0$62011bc8@tiburon> <5jtco1$757$1@netnews.mis.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1053fc,124bc44337efa593
X-Google-Attributes: gid1053fc,public
X-Google-Thread: 110e3b,124bc44337efa593
X-Google-Attributes: gid110e3b,public
X-Google-Thread: f5f6f,124bc44337efa593
X-Google-Attributes: gidf5f6f,public
X-Google-Thread: f645d,124bc44337efa593
X-Google-Attributes: gidf645d,public
From: Mark Wilson <markwilson@dial.pipex.com>
Subject: Re: HELP !!! ... How i can read INI files in VB4 ....
Date: 1997/04/28
Message-ID: <33644BF1.AC0@dial.pipex.com>
X-Deja-AN: 237821601
References: <01bc4bb2$2eb66ae0$62011bc8@tiburon> <5jtco1$757$1@netnews.mis.net>
To: James Chambers <nxs@mis.net>
Organization: Virtual Enterprises
Reply-To: markwilson@dial.pipex.com
Newsgroups: comp.lang.basic.visual,comp.lang.basic.visual.3rdparty,comp.lang.basic.visual.misc,es.comp.lenguajes.visual-basic