Reading/Writing to the Registry and .INI file??? 
Author Message
 Reading/Writing to the Registry and .INI file???

Please help this old main fraimer understand the
reading and writing to a .INI file or the Registry.

Why write to these files?  
What's the advantage?
Can you create a INI file in run-time?
Is there any reason you would want too?
Can anybody post an example of Reading the registry and .INI file.
Also and example of writing to the Registry and .INI file.

Can anyone explain the following code.
Whats with all the "$"s ?

Dim length, returned$

getinidata = ""
If section <> "" And keyword <> "" Then
    returned$ = Space$(256)
    length = GetPrivateProfileStringA(section, keyword, "0", returned$,
256, windir$ & "trs.ini")
    returned$ = Left$(returned$, length)
    getinidata = returned$
End If

                        Any help will be appreciated,
                                        Magic



Sat, 05 May 2001 03:00:00 GMT  
 Reading/Writing to the Registry and .INI file???

Quote:

>Please help this old main fraimer understand the
>reading and writing to a .INI file or the Registry.

>Why write to these files?

.INI files were Windows 3.1 technology.  They're obsolete for Windows
programming now, unless you're maintaining old code.  The reason you
would write things to the registry is to store configuration and
start-up information for your app.  Things like paths, colors, most
recently used file lists, form states and so on can all be saved in
the registry.

Quote:
>What's the advantage?

It saves you the trouble of writing your own configuration load and
save routines.

Quote:
>Can you create a INI file in run-time?

Yes.

Quote:
>Is there any reason you would want too?

Not any more, for previously stated reason.

Quote:
>Can anybody post an example of Reading the registry and .INI file.
>Also and example of writing to the Registry and .INI file.

Depends on what language you're using.  If you are using Visual Basic,
look up in your help file the functions "SaveSetting" and
"GetSetting".  To use the .INI file functions you would have to use
the Windows API functions "GetPrivateProfileString" and
"WritePrivateProfileString".

Quote:

>Can anyone explain the following code.
>Whats with all the "$"s ?

The dollar sign is the data type character for String.  Those are all
string variables.  Read up on data types.  I personally prefer not to
use the data type characters.  To me it makes the code too
busy-looking.  I like to prefix a variable name with a lowercase
letter denoting the data type and use the AS STRING or AS INTEGER . .
. etc. declarators after the variable name.  Like this:

Dim sMyString As String
Dim iMyInteger As Integer

and so on.  To me that's a lot more readable than lots of little funny
characters sprinkled all through my code.

jdm



Sat, 05 May 2001 03:00:00 GMT  
 Reading/Writing to the Registry and .INI file???
VB allows, although the use is going down, to type a variable by a type char
$ = string, %, #, etc are for different numerics.

So you can say

dim x as string
or
dim x$

and function that ends in $ like Left$ returns a string

ini files (windows system or private)  were used in W3 and to a lesser
extend in W95/95/NT to simulate a DB for holding system or app data over
runs. For eaxample the most recently used files list might be stored there
or a users name, or what every you want. Can you build ini files at run time
yes, you just create file with an ini extesion and close it, then use the
writeprivateprovile functions to populate it with defaults (or you include a
default with your app indstall packahe).

the registry is a fancy ini file with sections that hold system wide data,
like the location of a given control, lic data; and sections which refer to
a single given user on multi user system like NT.

Why would you use an INI or the registry for a given app is up to you. INI
use is going doing and registryy use is going up but either works. The
advantage of this over storing this type data in a DB or a text file is
registry and ini files are keyed and VB/OS searches for what you want.

The code you show gets the entire contents if the ini file at one time ( a
string of up to 256 chars)

hope that helps

Quote:
>Please help this old main fraimer understand the
>reading and writing to a .INI file or the Registry.

>Why write to these files?
>What's the advantage?
>Can you create a INI file in run-time?
>Is there any reason you would want too?
>Can anybody post an example of Reading the registry and .INI file.
>Also and example of writing to the Registry and .INI file.

>Can anyone explain the following code.
>Whats with all the "$"s ?

>Dim length, returned$

>getinidata = ""
>If section <> "" And keyword <> "" Then
>    returned$ = Space$(256)
>    length = GetPrivateProfileStringA(section, keyword, "0", returned$,
>256, windir$ & "trs.ini")
>    returned$ = Left$(returned$, length)
>    getinidata = returned$
>End If

> Any help will be appreciated,
> Magic



Sat, 05 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Reading/Writing to Registry and .INI file ????

2. Writing a VBS file which reads and writes to the registry

3. Read/Write INI Files w/Access 7.0

4. Ini-file, read write and empty lines.

5. Reading and writing from and to ini files

6. read/write an .ini file

7. Reading and writing to an INI file?

8. Reading and Writing to .ini files - help please.

9. Read and Write to INI files

10. Reading/writing to an INI file

11. Reading / Writing an INI file

12. Reading / Writing an INI file

 

 
Powered by phpBB® Forum Software