INI
Old
  (#1)
Maarten
Guest
 
Posts: n/a
Default INI - 06-04-2007, 08:50 AM

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



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: INI
Old
  (#2)
J French
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

On Sat, 22 Nov 2003 16:28:06 +0100, "Maarten" <EMAIL REMOVED>
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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#3)
Randy Birch
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

: 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.


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#4)
J French
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

On Sat, 22 Nov 2003 16:26:27 GMT, "Randy Birch"
<EMAIL REMOVED> wrote:

>: Look for SetPrivateProfileString
>
>Unless they're alising the APIs, it's WritePrivateProfileString(..)
>
>http://www.mvps.org/vbnet/code/file/pprofilebasic.htm


Apologies ...
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#5)
Kiteman \(Canada\)
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

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" <EMAIL REMOVED> wrote in message
news:3fbf8088$0$28311$EMAIL REMOVED .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
>
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#6)
Raoul Watson
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM


"Maarten" <EMAIL REMOVED> wrote in message
news:3fbf8088$0$28311$EMAIL REMOVED .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


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#7)
J French
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

On Sun, 23 Nov 2003 03:15:07 GMT, "Raoul Watson"
<EMAIL REMOVED> 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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#8)
John Lauwers
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

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" <EMAIL REMOVED> schreef in bericht
news:3fbf8088$0$28311$EMAIL REMOVED .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
>
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#9)
Raoul Watson
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM


"J French" <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED...
> On Sun, 23 Nov 2003 03:15:07 GMT, "Raoul Watson"
> <EMAIL REMOVED> 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


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.


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: INI
Old
  (#10)
J French
Guest
 
Posts: n/a
Default Re: INI - 06-04-2007, 08:50 AM

On Sun, 23 Nov 2003 12:48:18 GMT, "Raoul Watson"
<EMAIL REMOVED> 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
   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Contact Us - Forum Care Forums - Archive - Top