469,306 Members | 1,916 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

INI

hallow

i'm trying to make a simpel INI file, but it won't work

i want to write a value (of a selected printerport selected by an option
box)
to an INI file.

can someone plz help me.
thanks Maarten

Jul 17 '05 #1
9 3943
On Sat, 22 Nov 2003 16:28:06 +0100, "Maarten" <gu******@hotmail.com>
wrote:
hallow

i'm trying to make a simpel INI file, but it won't work

i want to write a value (of a selected printerport selected by an option
box)
to an INI file.

can someone plz help me.
thanks Maarten


www.AllAPI.net

Download their API Guide

Look for SetPrivateProfileString

Afterwards, look at Mid$() InStr() Left$()
- and do it yourself

BTW ... look in the VB Help for the Open Statement
Jul 17 '05 #2
: Look for SetPrivateProfileString

Unless they're alising the APIs, it's WritePrivateProfileString(..)

http://www.mvps.org/vbnet/code/file/pprofilebasic.htm

--

Randy Birch
MVP Visual Basic
http://www.mvps.org/vbnet/
Please respond only to the newsgroups so all can benefit.
Jul 17 '05 #3
On Sat, 22 Nov 2003 16:26:27 GMT, "Randy Birch"
<rg************@mvps.org> wrote:
: Look for SetPrivateProfileString

Unless they're alising the APIs, it's WritePrivateProfileString(..)

http://www.mvps.org/vbnet/code/file/pprofilebasic.htm


Apologies ...
Jul 17 '05 #4
Maarten, this is the way that I saved and read in an .ini file in a recent
program that I wrote (I cut out all the extras and just left the basics -
substituted variable name though).

' Save the initialization file
intFileNo = FreeFile
Open App.Path & "\Startup.ini" For Output As #intFileNo
Print #intFileNo, PrinterPortValue
close #intFileNo

'Read the initialization file
intFileNo = FreeFile
Open App.Path & "\Startup.ini" For Input As #intFileNo
Line Input #intFileNo, PrinterPortValue
Close #intFileNo
Exit Sub ' Exit to avoid handler.
"Maarten" <gu******@hotmail.com> wrote in message
news:3f***********************@reader1.news.skynet .be...
hallow

i'm trying to make a simpel INI file, but it won't work

i want to write a value (of a selected printerport selected by an option
box)
to an INI file.

can someone plz help me.
thanks Maarten

Jul 17 '05 #5

"Maarten" <gu******@hotmail.com> wrote in message
news:3f***********************@reader1.news.skynet .be...
hallow

i'm trying to make a simpel INI file, but it won't work

i want to write a value (of a selected printerport selected by an option
box)
to an INI file.

can someone plz help me.
thanks Maarten


Some good suggestions are already given here.

But if you want you can also use the built in function.

' Place some settings in the registry.

SaveSetting "MyApp","Printerport", "Port", portvalue

This writes whatever value is in portvalue into the registry of the current
user.
Portvalue of course can have a default setting.

To remove the key (should the need arise), use DeleteSetting "MyApp",
"Printerport"

Beste wensen van New York
Jul 17 '05 #6
On Sun, 23 Nov 2003 03:15:07 GMT, "Raoul Watson"
<Wa*****@IntelligenCIA.com> wrote:

<snip>
Some good suggestions are already given here.

But if you want you can also use the built in function.

' Place some settings in the registry.

SaveSetting "MyApp","Printerport", "Port", portvalue

This writes whatever value is in portvalue into the registry of the current
user.
Portvalue of course can have a default setting.

To remove the key (should the need arise), use DeleteSetting "MyApp",
"Printerport"


But that uses the Registry - which is another kettle of fish
Jul 17 '05 #7
Public 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 Declare Function WritePrivateProfileString Lib "kernel32" Alias
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal
lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Function SaveIni(PsName As String, PsSection As String, Pskey As String,
PsSetting As String)
WritePrivateProfileString PsSection, Pskey, PsSetting, PsName

End Function

Function GetIni(PsName As String, PsSection As String, Pskey As String,
PsDefault As String) As String
Dim s As String * 256, initext
initext = GetPrivateProfileString(PsSection, Pskey, PsDefault, s, Len(s),
PsName)
GetIni = Left$(s, initext)

End Function

that uses a lokal ini file like the old days,

greet John
"Maarten" <gu******@hotmail.com> schreef in bericht
news:3f***********************@reader1.news.skynet .be...
hallow

i'm trying to make a simpel INI file, but it won't work

i want to write a value (of a selected printerport selected by an option
box)
to an INI file.

can someone plz help me.
thanks Maarten

Jul 17 '05 #8

"J French" <er*****@nowhere.com> wrote in message
news:3f****************@news.btclick.com...
On Sun, 23 Nov 2003 03:15:07 GMT, "Raoul Watson"
<Wa*****@IntelligenCIA.com> wrote:

<snip>
Some good suggestions are already given here.

But if you want you can also use the built in function.

' Place some settings in the registry.

SaveSetting "MyApp","Printerport", "Port", portvalue

This writes whatever value is in portvalue into the registry of the currentuser.
Portvalue of course can have a default setting.

To remove the key (should the need arise), use DeleteSetting "MyApp",
"Printerport"


But that uses the Registry - which is another kettle of fish


It will write an INI file on a 16 bit Windows. The key to remember is that
if you don't need individual settings then just write any file with
settings. If you need individualized settings obviously the file or ini
method won't work very well.
Jul 17 '05 #9
On Sun, 23 Nov 2003 12:48:18 GMT, "Raoul Watson"
<Wa*****@IntelligenCIA.com> wrote:

<snip>
But that uses the Registry - which is another kettle of fish


It will write an INI file on a 16 bit Windows. The key to remember is that
if you don't need individual settings then just write any file with
settings. If you need individualized settings obviously the file or ini
method won't work very well.


Yes, it will write to an INI file on Win16
- but under Win 32, it has nothing to do with INI files

Individualized settings are also something of a red herring

If one wants them, then one 'designs them in'

If you had asked 'have you considered the registry'
or 'do you require individualized settings'

then your reply would not have been misleading
- bear in mind the OP obviously is just getting into these areas
- and is therefore easily mis-lead
Jul 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.