INI

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Maarten

    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



  • J French

    #2
    Re: INI

    On Sat, 22 Nov 2003 16:28:06 +0100, "Maarten" <gurkjaan@hotma il.com>
    wrote:
    [color=blue]
    >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[/color]



    Download their API Guide

    Look for SetPrivateProfi leString

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

    BTW ... look in the VB Help for the Open Statement

    Comment

    • Randy Birch

      #3
      Re: INI

      : Look for SetPrivateProfi leString

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

      VBnet provides Intermediate and Advanced Win32 API code for VB developers. Comprehensive Code, FAQ, Developers Resources & News, alphabetical API/Type/Constant/Method Index, along with the largest Visual Basic-related links list on the net.


      --

      Randy Birch
      MVP Visual Basic

      Please respond only to the newsgroups so all can benefit.


      Comment

      • J French

        #4
        Re: INI

        On Sat, 22 Nov 2003 16:26:27 GMT, "Randy Birch"
        <rgb_removethis @mvps.org> wrote:
        [color=blue]
        >: Look for SetPrivateProfi leString
        >
        >Unless they're alising the APIs, it's WritePrivatePro fileString(..)
        >
        >http://www.mvps.org/vbnet/code/file/pprofilebasic.htm[/color]

        Apologies ...

        Comment

        • Kiteman \(Canada\)

          #5
          Re: INI

          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.i ni" For Output As #intFileNo
          Print #intFileNo, PrinterPortValu e
          close #intFileNo

          'Read the initialization file
          intFileNo = FreeFile
          Open App.Path & "\Startup.i ni" For Input As #intFileNo
          Line Input #intFileNo, PrinterPortValu e
          Close #intFileNo


          Exit Sub ' Exit to avoid handler.
          "Maarten" <gurkjaan@hotma il.com> wrote in message
          news:3fbf8088$0 $28311$ba620e4c @reader1.news.s kynet.be...[color=blue]
          > 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
          >
          >
          >[/color]


          Comment

          • Raoul Watson

            #6
            Re: INI


            "Maarten" <gurkjaan@hotma il.com> wrote in message
            news:3fbf8088$0 $28311$ba620e4c @reader1.news.s kynet.be...[color=blue]
            > 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
            >[/color]

            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","Printe rport", "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",
            "Printerpor t"

            Beste wensen van New York


            Comment

            • J French

              #7
              Re: INI

              On Sun, 23 Nov 2003 03:15:07 GMT, "Raoul Watson"
              <WatsonR@Intell igenCIA.com> wrote:

              <snip>[color=blue]
              >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","Printe rport", "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 "
              >[/color]

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

              Comment

              • John Lauwers

                #8
                Re: INI

                Public Declare Function GetPrivateProfi leString Lib "kernel32" Alias
                "GetPrivateProf ileStringA" (ByVal lpApplicationNa me As String, ByVal
                lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedStrin g As
                String, ByVal nSize As Long, ByVal lpFileName As String) As Long
                Public Declare Function WritePrivatePro fileString Lib "kernel32" Alias
                "WritePrivatePr ofileStringA" (ByVal lpApplicationNa me 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)
                WritePrivatePro fileString 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 = GetPrivateProfi leString(PsSect ion, 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" <gurkjaan@hotma il.com> schreef in bericht
                news:3fbf8088$0 $28311$ba620e4c @reader1.news.s kynet.be...[color=blue]
                > 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
                >
                >
                >[/color]


                Comment

                • Raoul Watson

                  #9
                  Re: INI


                  "J French" <erewhon@nowher e.com> wrote in message
                  news:3fc09502.1 [email protected] tclick.com...[color=blue]
                  > On Sun, 23 Nov 2003 03:15:07 GMT, "Raoul Watson"
                  > <WatsonR@Intell igenCIA.com> wrote:
                  >
                  > <snip>[color=green]
                  > >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","Printe rport", "Port", portvalue
                  > >
                  > >This writes whatever value is in portvalue into the registry of the[/color][/color]
                  current[color=blue][color=green]
                  > >user.
                  > >Portvalue of course can have a default setting.
                  > >
                  > >To remove the key (should the need arise), use DeleteSetting "MyApp",
                  > >"Printerport "
                  > >[/color]
                  >
                  > But that uses the Registry - which is another kettle of fish[/color]

                  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.


                  Comment

                  • J French

                    #10
                    Re: INI

                    On Sun, 23 Nov 2003 12:48:18 GMT, "Raoul Watson"
                    <WatsonR@Intell igenCIA.com> wrote:

                    <snip>[color=blue][color=green]
                    >> But that uses the Registry - which is another kettle of fish[/color]
                    >
                    >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.[/color]

                    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

                    Comment

                    Working...